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 · 428 阅读 · 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 · 384 阅读 · 0 评论 -
AlertView
- (IBAction)showAlert { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hello,World" message:@"This is my first app!"原创 2013-02-26 20:09:33 · 402 阅读 · 0 评论 -
Loads the local HTML file into the web view in the app
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@原创 2013-02-28 00:22:41 · 640 阅读 · 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 Eye Buttonpp27 Alert View popuppp28 ViewCo原创 2013-02-26 19:59:55 · 665 阅读 · 0 评论 -
AboutView -- Create the second window in the app
1. create the second window by new file -> objective-C class (subclass of ViewController). then .xib, .h and .m 2. set Action in the first view to trigger the second window - (IBAction)showI原创 2013-02-27 20:54:21 · 331 阅读 · 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 · 361 阅读 · 0 评论 -
AboutView -- Close the second window
1 Set the Action in the second window 2 in .m file, implement the - (IBAction)close method. pp 120 // AboutViewController.m -(IBAction)close { [self.presentingViewController dismiss原创 2013-02-27 21:15:20 · 324 阅读 · 0 评论 -
Delegates in table view
The delegation pattern The 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 · 299 阅读 · 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 · 613 阅读 · 0 评论 -
Checklists
This is the second app How it looks like pp2 : a to-do list The 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 · 477 阅读 · 0 评论 -
From NSDate to string
- (void)updateViewDateLabel { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateStyle:NSDateFormatterMediumStyle]; [formatter setTimeStyle:NSDateForma原创 2013-03-19 16:35:56 · 741 阅读 · 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 · 762 阅读 · 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) IBOutlet U原创 2013-02-27 15:39:17 · 322 阅读 · 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 · 408 阅读 · 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 · 595 阅读 · 0 评论 -
Reading Text from Text Field
pp105 property - (void)Done { NSLog(@"Contents of the text field: %@",self.textField.text); //close the window [self.presentingViewControllerdismissViewControllerAnimated:YES原创 2013-03-06 00:37:10 · 635 阅读 · 0 评论 -
Adding new items to the Checklist
pp 67 Add a navigation controller Open 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 · 742 阅读 · 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 · 608 阅读 · 0 评论 -
Editing Existing Items in Checklist
- (void)configureCheckmarkForCell:(UITableViewCell *)cell withChecklistItem:(ChecklistsItem *)item { UILabel *label = (UILabel *)[cell viewWithTag:1001]; label.text原创 2013-03-06 23:00:43 · 580 阅读 · 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 · 485 阅读 · 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 · 536 阅读 · 0 评论 -
ViewDidLoad
Do some setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.原创 2013-02-27 10:23:41 · 453 阅读 · 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 · 295 阅读 · 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 · 380 阅读 · 0 评论 -
iOS 5 by Tutorials: Tips
1 Technically speaking you don’t need to set instance variables to nil in dealloc, because the object will automatically release any instance variables when it gets deleted.原创 2013-08-04 16:26:18 · 978 阅读 · 0 评论
分享