随笔分类 - iOS
iOS Dev
摘要:ProblemYou want to display an image instead of text as the title of the current view controlleron the navigation controllerSolutionUse the titleView property of the view controller’s navigation item- (void)viewDidLoad { [super viewDidLoad]; /* Create an Image View to replace the Title View */ ...
阅读全文
摘要:ProblemYou would like to directly manipulate the array of view controllers associated with aspecific navigation controllerSolutionUse the viewControllers property of the UINavigationController class to access andmodify the array of view controllers associated with a navigation controller- (void) goB
阅读全文
摘要:ProblemYou would like to allow your users to move from one view controller to the other witha smooth and built-in animation.SolutionUse an instance of UINavigationController.What it's likeIf you’ve used an iPhone, iPod Touch, or iPad before, chances are that you have alreadyseen a navigation con
阅读全文
摘要:You want to be able to allow your users to share content inside your apps with theirfriends, through an interface, such as Facebook and Twitter.SolutionCreate an instance of the UIActivityViewController class and share your contentthrough this class.eg:you have a text field where the user can enter
阅读全文
摘要:Presenting and Managing Views with UIViewControllerProblemYou want to switch among different views in your application.SolutionUse the UIViewController class.(Apple’s strategy for iOS development was to use the model-view-controller (MVC) divisionof labor. Views are what get displayed to users, whil
阅读全文
摘要:You would like to present a few options to your users from which they can pick anoption, through a UI that is compact, simple, and easy to understand.effect:1. declare control#import "ViewController.h"@interface ViewController ()@property (nonatomic, strong) UISegmentedControl *mySegmented
阅读全文
摘要:Picking the Date and Time with UIDatePickereffect:1. declaring a property of type UIDatePicker#import "ViewController.h"@interface ViewController ()@property (nonatomic, strong) UIDatePicker *myDatePicker;@end@implementation ViewController...2. instantiate the date picker- (void)viewDidLoa
阅读全文
摘要:Creating and Using Switches with UISwitchYou would like to give your users the ability to turn an option on or off.effect as follow:SolutionUse the UI...
阅读全文
摘要:1. Viewspresentation:A view (an object whose class is UIView or a subclass of UIView) knows how to draw itself into a rectangular area of the interface.eg: you can drag an interface widget, such as a UIButton, into a view in the nib editor; when the app runs, the button appears, and works properly.i
阅读全文
摘要:synthesize creates setter and getter(从Objective-C 2.0开始,合成可自动生成存取方法)the setter is used by IOS to set the pointer of the object on storyboardwe uses getter anytime we want to call the object on storyboard and send messages属性合成的步骤:1) 在接口部分(也就是头文件)使用@property指令标识属性 eg: @property int numerator, denomina
阅读全文
摘要:NSString (Immutable)NSMutableString (rarely used)NSNumberNSValueNSData (bits)NSDateNSArray (Immutable)- once you create the array, you cannot add or remove objectseg:NSArray *primaryColors = [NSArray arayWithObjects:@"red", @"yellow", @"blue", nil];NSMutableArrayNSDicti
阅读全文
摘要:1. setAlertViewStyle:UIAlertViewStyleSecureTextInputUIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Password" message:@"Please enter your password:" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil]; [alertView setAlertViewS
阅读全文
摘要:Application Delegate(应用程序委托)Application Name: SingleViewSingleViewAppDelegate.h#import @interface SingleViewAppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window;@property (strong, nonatomic) SingleViewViewController *viewController;@endSingleViewAppDelegate.m#import "Singl..
阅读全文
摘要:OutletActionViewController.h#import @interface OutletActionViewController : UIViewController{ IBOutlet UITextField *txtName;}// expose the outlet as a property@property (nonatomic, retain) UITextField *txtName;// declare the action- (IBAction) btnClicked: (id) sender;@endOutletActionViewControlle...
阅读全文
摘要:UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"You've been delivered an alert" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTi...
阅读全文
摘要:Objects and classesA class consists primarily of two things: variables that can store data and methodsthat can perform operations.SubclassesClasses can also inherit functionality from an existing classInstance and class variablesChanging the value of an instance variable in one objectwill not affect
阅读全文
摘要:类接口文件(MathDiv.h)#import<Foundation/Foundation.h>//DefinetheFractionclass@interfaceFraction:NSObject{intdividend;intdivider;}@propertyintdividend,divider;-(void)print;-(void)setTo:(int)nover:(int)d;-(double)convertToNum;@end类实现文件(MathDiv.m)#import"Fraction.h"@implementationFraction@sy
阅读全文
摘要:1. 什么是Cocal TouchCocoa Touch is the collection of software frameworks that isused to build iOS applications and the runtime that those applications are executedwithin. Cocoa Touch includes hundreds of classes for managing everything frombuttons to URLs.(Cocoa Touch是IOS构建应用程序的框架集合, 它包括了许多类用来操作IOS上的许.
阅读全文
摘要:XCode中引入了静态分析器,用于发现普通编译错误以外的错误选择Build->Build and Analyze请看下面这段代码#import<Foundation/FOundation.h>intmain(intagrc,constchar*argv[]){NSAutoreleasePool*pool=[[NSAutoreleasePoolalloc]init];NSDate*date=[[NSDatealloc]init];NSLog(@"Thetimeis:%@",date);[pooldrain];return0;}上面这段代码中, date对象在
阅读全文
摘要:1. 声明变量 <Type> <Variable Name>;2. 基本数据类型 数字类型: int/float/double3. 对象类型 Objective-C中的对象类型必须使用指针 eg: NSString *userName;4. 对象的分配/初始化/释放 在对象使用前,必须分配内存和进行初始化 eg: [[<class name> alloc] init];UILabel*myLabel;myLabel=[[UILabelalloc]init];5. 快速初始化 一些内建的快速方法可以方便我们进行初始化NSURL*iPhoneURL;iPhone
阅读全文

浙公网安备 33010602011771号