아이폰강의(4) pdf

1,447 views
1,272 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,447
On SlideShare
0
From Embeds
0
Number of Embeds
270
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

아이폰강의(4) pdf

  1. 1. Chapter 6 Bit Academy
  2. 2. • • MVC • •
  3. 3. plain tableview grouped tableview - section section header section footer . - row
  4. 4. TableviewCell row tableViewCell . 4 . image is allowed image is not allowed image is not allowedimage is allowed subtitle subtitle right aligned main title is in blue subtitle left aligned
  5. 5. • UITableViewController Class : UITableViewDelegate & UITableViewDataSource , , TableView . • UITableView Class : • UITableViewCell Class : row
  6. 6. Cell Object disclosure indicators, detail disclosure controls, control objects such as sliders or switches, and custom views , (reordering) .
  7. 7. Accessary View Disclosure indicator— UITableViewCellAccessoryDisclosureIndicator. disclosure indicator . Detail disclosure button— UITableViewCellAccessoryDetailDisclosureButton. detail disclosure button . . Check mark—UITableViewCellAccessoryCheckmark. . .
  8. 8. DataSource & Delegate Protocol - UITableView Data Source delegate . application delegate custom UITableViewController . - data source UITableViewDataSource protocol delegate UITableViewDelegate protocol . - data source UITableView . row , . - Delegate .
  9. 9. Data Source Protocol Data Source Object (TableViewController or Application Delegate object) ( ) UITableView Data Source Protocol Configuring a Table View 1 – tableView:cellForRowAtIndexPath:  required method . 2 – numberOfSectionsInTableView: 3 – tableView:numberOfRowsInSection:  required method 4 – sectionIndexTitlesForTableView: . 5 – tableView:sectionForSectionIndexTitle:atIndex: 6 – tableView:titleForHeaderInSection: Data Source Object 7 – tableView:titleForFooterInSection: Inserting or Deleting Table Rows 1 – tableView:commitEditingStyle:forRowAtIndexPath: 2 – tableView:canEditRowAtIndexPath: Reordering Table Rows 1 2 – tableView:canMoveRowAtIndexPath: – tableView:moveRowAtIndexPath:toIndexPath: Delegate
  10. 10. Delegate Protocol Delegate Object (TableViewController or Application Delegate object) ( ) UITableView DelegateProtocol Configuring Rows for the Table View 1 – tableView:heightForRowAtIndexPath: 2 – tableView:indentationLevelForRowAtIndexPath: 3 – tableView:willDisplayCell:forRowAtIndexPath:RowAtIndexPath Delegate Managing Accessory Views 1 – tableView:accessoryButtonTappedForRowWithIndexPath: . 2 – tableView:accessoryTypeForRowWithIndexPath: Deprecated in iOS 3.0 . Managing Selections 1 – tableView:willSelectRowAtIndexPath: 2 – tableView:didSelectRowAtIndexPath: 3 – tableView:willDeselectRowAtIndexPath: 4 – tableView:didDeselectRowAtIndexPath: Modifying the Header and Footer of Sections 1 – tableView:viewForHeaderInSection: 2 – tableView:viewForFooterInSection: 3 – tableView:heightForHeaderInSection: 4 – tableView:heightForFooterInSection: Editing Table Rows 1 – tableView:willBeginEditingRowAtIndexPath: 2 – tableView:didEndEditingRowAtIndexPath: 3 – tableView:editingStyleForRowAtIndexPath: 4 – tableView:titleForDeleteConfirmationButtonForRowAtIndexPath: 5 – tableView:shouldIndentWhileEditingRowAtIndexPath: Reordering Table Rows 1 – tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:
  11. 11. RootViewController.m TableView SimpleHumanResourceAppDelegate.m applicationDidFinishLaunching UIApplication NSInteger numberOfSectionsInTableView UITableView tableView application ; " personnel alloc initWithArray self createEmployees ; " window addSubview navigationController view ; window makeKeyAndVisible ; DataSource TableView & Delegate NSArray NSInteger tableView UITableView tableView numberOfRowsInSection NSInteger section" rowCount self appDelegate .personnel count ; rowCount;   TableView Data Source row tableView:cellForRowAtIndexPath: cell TableView . UITableViewCell tableView UITableView tableView cellForRowAtIndexPath indexPath   CellIdentifier ;   UITableViewCell cell tableView dequeueReusableCellWithIdentifier CellIdentifier ; cell cell UITableViewCell alloc initWithStyle UITableViewCellStyleValue1 reuseIdentifier CellIdentifier autorelease ;   " personnel self appDelegate .personnel; " employee personnel objectAtIndex indexPath.row ; " cell.textLabel.text employee valueForKey ; " cell.detailTextLabel.text employee valueForKey ; cell;
  12. 12. cell . , reuseIdentifier . reuseIdentifier UITableViewCell tableView UITableView tableView cellForRowAtIndexPath indexPath  CellIdentifier ;  UITableViewCell cell tableView dequeueReusableCellWithIdentifier CellIdentifier ; cell cell UITableViewCell alloc initWithStyle UITableViewCellStyleValue1 reuseIdentifier CellIdentifierautorelease ; " personnel self appDelegate .personnel;" employee personnel objectAtIndex indexPath.row ;" cell.textLabel.text employee valueForKey ;" cell.detailTextLabel.text employee valueForKey ; cell;
  13. 13. XCode Navigation-based application template 1. In Xcode, choose New Project from the File menu. 2. Select the Navigation-based Application template project and click Choose. 3. Specify a name and location for the project and click Save.RootViewController : datasource, delegateMyTableViewAppDelegate : applicationdelegateMainWindow.xib:RootViewController.xib:
  14. 14. MainWindow.Xib MainWindow.xib nib file Root View Controller View Table View . The application delegate displaying the initial user interface - (void)applicationDidFinishLaunching:(UIApplication *)application { [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; } viewviewController . RootViewController TableViewController tableView .
  15. 15. root view controller’s nib for view document window Root View Controller object . NIB Name RootViewController . root view controller root view controller NIB Name RootViewController.Nib .
  16. 16. RootViewController.xib RootViewController table view , File’s Owner (RootViewController) . tableView (UITableViewController Class) Returns the table view managed by the controller object. @property(nonatomic, retain) UITableView *tableView view property inherited from UIViewControllerTableView propertydataSourceThe object that acts as the data source of the receiving table view.@property(nonatomic, assign) id<UITableViewDataSource> dataSourceDiscussionThe data source must adopt the UITableViewDataSource protocol. The data source is not retained. RootViewControllerdelegate Table View propertyThe object that acts as the delegate of the receiving table view. TableView dataSource protocol delegate protocol@property(nonatomic, assign) id<UITableViewDelegate> delegate RootViewController .DiscussionThe delegate must adopt the UITableViewDelegate protocol. The delegate is not retained.

×