User Tools

Site Tools


ios-labs-s14:basics-tables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
ios-labs-s14:basics-tables [2014/02/26 13:26]
mbarboi
ios-labs-s14:basics-tables [2015/10/30 11:47]
mbarboi
Line 12: Line 12:
  
 The delegate methods required by a UITableView:​ The delegate methods required by a UITableView:​
-  * -(NSInteger) numberOfSectionsInTableView:​(UITableView *)tableView ​ +  * func tableView(tableView:​ UITableViewnumberOfRowsInSection ​sectionInt-> Int
-  * -(NSInteger) ​tableView:(UITableView ​*)tableView ​numberOfRowsInSection:​(NSInteger)section ​+
  
 Return integers to the table. Return integers to the table.
  
-  * -(UITableViewCell *) tableView:(UITableView ​*)tableView ​cellForRowAtIndexPath:​(NSIndexPath ​*)indexPath ​+  * func tableView(tableView: UITableViewcellForRowAtIndexPath ​indexPath: NSIndexPath) ​-> UITableViewCell
  
 Method receives a cell that is **dequeued** from memory (has been scrolled off the screen and is no longer visible) for editing. Method is called when the table needs to display a new cell. Developer must change the views within the cell to represent model information,​ commonly using //​indexPath.row//​ as an index into an array. Cell is returned at the end of the method, at which point the table loads it into memory and onto the screen. Method receives a cell that is **dequeued** from memory (has been scrolled off the screen and is no longer visible) for editing. Method is called when the table needs to display a new cell. Developer must change the views within the cell to represent model information,​ commonly using //​indexPath.row//​ as an index into an array. Cell is returned at the end of the method, at which point the table loads it into memory and onto the screen.
Line 23: Line 22:
 Note that cells have a property called **reuse identifier**,​ a string used to identify types of cells in the case of multiple tables. Set this property using the **Attributes Inspector** of InterfaceBuilder,​ access it in the //​cellForRowAtIndexPath//​ method. Note that cells have a property called **reuse identifier**,​ a string used to identify types of cells in the case of multiple tables. Set this property using the **Attributes Inspector** of InterfaceBuilder,​ access it in the //​cellForRowAtIndexPath//​ method.
  
-  * -(void)tableView:(UITableView ​*)tableView ​didSelectRowAtIndexPath:​(NSIndexPath ​*)indexPath+  * func tableView(tableView: UITableViewdidSelectRowAtIndexPath ​indexPath: NSIndexPath)
  
 Called when a user touches a cell. Includes the index of the touched cell in //​indexPath.row.// ​ Called when a user touches a cell. Includes the index of the touched cell in //​indexPath.row.// ​
ios-labs-s14/basics-tables.txt · Last modified: 2015/10/30 11:47 by mbarboi