Christina Moulton, Teak Mobile Inc.
Segues + Scenes + View Controllers
Quick flow mock up
Easy to create & see transitions
Gestalt view
Can use multiple storyboards & xibs
Cleaner code, less boilerplate
Make Brian do it ;)
iOS5+ only
Clutter / screen size
Version control conflicts
Can’t do all transitions / custom views (yet)
Create an app with a tableview
The tableview should have 2 sections: Fruits & Vegetables
Each section should list a few items that are fruits or vegetables
Create a project (single view app)
Replace UIViewController with UITableViewController (check "Is Initial View Controller")
Set the tableview cell to use a prototype cell with style "Basic" and cell identifier "Cell"
Check that tableview the datasource & delegate IBOutlets are hooked up
Remove the auto-generated ViewController class and add a custom UITableViewController
Use an NSArray to hold the data for each section
Fill the array with a few strings:
@interface FruitVsVegTableVieController: UITableViewController {
NSArray *_vegetables;
NSArray *_fruits;
}
@end
- (void)viewDidLoad
{
[super viewDidLoad];
_vegetables = @[@"carrot", @"radish", @"beet"];
_fruits = @[@"apple", @"orange", @"tomato"];
}
Implement the datasource & delegate methods:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
return (section == 0)? @"Vegetables": @"Fruit";
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return (section == 0)? _vegetables.count: _fruits.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"Cell"
forIndexPath:indexPath];
if (indexPath.section == 0)
{
cell.textLabel.text = _vegetables[indexPath.row];
}
else
{
cell.textLabel.text = _fruits[indexPath.row];
}
return cell;
}
Embed tableview controller in navigation controller
Switch to NSMutableArrays and use mutableCopy
_vegetables = [@[@"carrot", @"radish", @"beet"] mutableCopy];
_fruits = [@[@"apple", @"orange", @"tomato"] mutableCopy];
Uncomment & Implement:
self.navigationItem.rightBarButtonItem = self.editButtonItem;
- (BOOL)tableView:(UITableView *)tableView
canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
Delegate methods
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
if (indexPath.section == 0)
{
[_vegetables removeObjectAtIndex:indexPath.row];
}
else
{
[_fruits removeObjectAtIndex:indexPath.row];
}
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
- (void)tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
toIndexPath:(NSIndexPath *)toIndexPath;
{
NSString * objectToMove;
if (fromIndexPath.section == 0)
{
objectToMove = _vegetables[fromIndexPath.row];
[_vegetables removeObject:objectToMove];
}
else
{
objectToMove = _fruits[fromIndexPath.row];
[_fruits removeObject:objectToMove];
}
if (toIndexPath.section == 0)
{
[_vegetables insertObject:objectToMove atIndex:toIndexPath.row];
}
else
{
[_fruits insertObject:objectToMove atIndex:toIndexPath.row];
}
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
NSString *selectedFood;
if (indexPath.section == 0)
{
selectedFood = _vegetables[indexPath.row];
}
else
{
selectedFood = _fruits[indexPath.row];
}
return ![selectedFood isEqualToString:@"tomato"];
}
Toolbar
Status bar
Navigation bar
Tab bar
Search bar
Images from Apple HIG
UITableview & UITableviewCell
Images from Apple HIG
UICollectionView
Images from Apple HIG
UIImageView & UIImage
UIWebView
UITextview
UIScrollView
UIPage ViewController
Map Kit: MKMapView
Images from Apple HIG
UIPopoverController (iPad only)
UISplitViewController (iPad only)
Images from Apple HIG
Activity indicator (spinner)
Picker / Date Picker
Buttons
Label
Progress view
Refresh control
Segmented control
Slider
Stepper
Switch
Text field
Images from Apple HIG
Alert
Action sheet
Modal view
Images from Apple HIG
Christina Moulton, Teak Mobile Inc.