
The iOS Apprentice
chuanyituoku
这个作者很懒,什么都没留下…
展开
-
data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 1;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *转载 2013-02-28 23:15:34 · 437 阅读 · 0 评论 -
Action methods vs. normal methods
The difference between an action method and a regular method: Nothing.An action method is really just the same as any other method. The only special thing is the (IBAction) specifier. This allows In原创 2013-02-27 15:47:28 · 397 阅读 · 0 评论 -
AlertView
- (IBAction)showAlert{ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hello,World" message:@"This is my first app!"原创 2013-02-26 20:09:33 · 412 阅读 · 0 评论 -
Loads the local HTML file into the web view in the app
- (void)viewDidLoad{ [superviewDidLoad]; // Do any additional setup after loading the view from its nib. NSString *htmlFile = [[NSBundlemainBundle] pathForResource:@原创 2013-02-28 00:22:41 · 692 阅读 · 0 评论 -
Bull's Eye
If you have the imagination and perseverance there is no limit to what you can make these cool little devices do.pp16 start the first app Bull's EyeButtonpp27Alert View popuppp28ViewCo原创 2013-02-26 19:59:55 · 676 阅读 · 0 评论 -
AboutView -- Create the second window in the app
1. create the second window by new file -> objective-C class (subclass ofViewController). then .xib, .h and .m2. set Action in the first view to trigger the second window - (IBAction)showI原创 2013-02-27 20:54:21 · 342 阅读 · 0 评论 -
Add a simple crossfade
Add a simple crossfade after the Start Over button is pressed, so the transition back to round one won't seem so abrupt.pp146#import - (IBAction)startOver{ CATransition *tr原创 2013-02-28 01:04:35 · 367 阅读 · 0 评论 -
AboutView -- Close the second window
1 Set the Action in the second window2 in .m file, implement the - (IBAction)close method.pp 120// AboutViewController.m-(IBAction)close{ [self.presentingViewControllerdismiss原创 2013-02-27 21:15:20 · 332 阅读 · 0 评论 -
Delegates in table view
The delegation patternThe concept of delegation is very common in iOS. An object will often rely on another object to help it out with certain tasks. This separation of concerns keeps the system sim原创 2013-03-01 02:19:53 · 314 阅读 · 0 评论 -
Primitive values and Objects
Dictionaries cannot contain primitive values such as int and BOOL, only objects. The same thing goes for arrays. If you want to put an int or BOOL values into a dictionary or array, you have to conver原创 2013-03-18 06:56:26 · 624 阅读 · 0 评论 -
Checklists
This is the second appHow it looks like pp2 : a to-do listThe app lets you organise to-do items into lists and then check off these items once you're done with them. You can set a reminder on a to原创 2013-02-28 22:19:40 · 490 阅读 · 0 评论 -
From NSDate to string
- (void)updateViewDateLabel{ NSDateFormatter *formatter = [[NSDateFormatteralloc] init]; [formatter setDateStyle:NSDateFormatterMediumStyle]; [formatter setTimeStyle:NSDateForma原创 2013-03-19 16:35:56 · 758 阅读 · 0 评论 -
MyLocations
MyLocations, an app that uses Core Location framework to obtain GPS coordinations for the user's whereabout, Map Kit to show the user's favourite locations on a map, the iPhone's camera and photo libr原创 2013-03-21 07:50:08 · 776 阅读 · 1 评论 -
Let the label display variable values on screen
To do that, we need to accomplish two things:1 Create a reference to the label so we can send it messages.2 Give the label new text to display@property (nonatomic,strong) IBOutletU原创 2013-02-27 15:39:17 · 330 阅读 · 0 评论 -
Properties vs instance variables
Properties and instance variables have a lot in common. In fact, when you use @synthesize to create the property, it is "backed" by an ivar. That means our slider property stores its value in an insta原创 2013-02-27 12:03:04 · 419 阅读 · 0 评论 -
Deleting rows in table view Checklist
//enable swipe-to-delete- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ [items removeObjectAtI原创 2013-03-05 14:16:29 · 609 阅读 · 0 评论 -
Reading Text from Text Field
pp105property- (void)Done{ NSLog(@"Contents of the text field: %@",self.textField.text); //close the window [self.presentingViewControllerdismissViewControllerAnimated:YES原创 2013-03-06 00:37:10 · 645 阅读 · 0 评论 -
Adding new items to the Checklist
pp 67Add a navigation controllerOpen a new Add item screen that let the user type the text for items.- (IBAction)addItem{ int newRowIndex = [itemscount]; //Create原创 2013-03-05 05:34:32 · 756 阅读 · 0 评论 -
Protocols, delegate
In Objective-C, protocol is simply a name for the groups of methods. A protocol doesn't have instance variables, and it doesn't implement any methods it declares. It just says, any object that conform原创 2013-03-06 21:08:43 · 616 阅读 · 0 评论 -
Editing Existing Items in Checklist
- (void)configureCheckmarkForCell:(UITableViewCell *)cell withChecklistItem:(ChecklistsItem *)item{ UILabel *label = (UILabel *)[cellviewWithTag:1001]; label.text原创 2013-03-06 23:00:43 · 590 阅读 · 0 评论 -
Saving and Loading the Checklist Items
Saving- (NSString *)documentsDirectory{ NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);//asd NSString *documentsDirectory = [pat原创 2013-03-08 06:15:37 · 495 阅读 · 0 评论 -
Converting the app to landscape
To convert our app from portrait into landscape, we have to do three things:1 Make the view from BullsEyeViewController.xib landscape instead of portrait.2 Change one line of code in BullsEyeViewC原创 2013-02-26 23:09:54 · 543 阅读 · 0 评论 -
ViewDidLoad
Do some setup after loading the view, typically from a nib.- (void)viewDidLoad{ [superviewDidLoad];// Do any additional setup after loading the view, typically from a nib.原创 2013-02-27 10:23:41 · 465 阅读 · 0 评论 -
Properties and Outlets
These three steps are necessary for just about any property you add to the view controller if that property refers to a view in the nib:1 add @property to the .h file,2 connect the outlet in Inter原创 2013-02-27 11:47:06 · 302 阅读 · 0 评论 -
Generating the random number
You can't really get a computer to generate numbers that are truly random and unpredictable, but we can employ a so-called pseudo-random generator to spit out numbers that at least appear that way.原创 2013-02-27 12:17:21 · 392 阅读 · 0 评论 -
iOS 5 by Tutorials: Tips
1 Technically speaking youdon’t need tosetinstance variables to nilin dealloc, because the object will automatically release any instance variables when it gets deleted.原创 2013-08-04 16:26:18 · 988 阅读 · 0 评论