Ios ui basics 07 and iosui07
TableView
Attribute
// Set the cell height of each row @ property (nonatomic) CGFloat rowHeight; // set the height of each set of headers @ property (nonatomic) CGFloat sectionHeaderHeight; // set the split line color @ property (nonatomic, retain) UIColor * separatorColor // set the header control @ property (nonatomic, retain) UIView * tableHeaderView; // set the table tail control @ property (nonatomic, retain) UIView * tableFooterView; // 2. high self. tableView. sectionHeaderHeight = 55; self. tableView. sectionFooterHeight = 22; // 3. set the header/tail view self of the entire tablView. tableView. tableHeaderView = [[UISwitch alloc] init]; self. tableView. tableFooterView = [UIButton buttonWithType: UIButtonTypeInfoDark]; // 4. set our split line color (clearColor is equivalent to canceling the system split line) // self. tableView. separatorColor = [UIColor clearColor]; // 5. set the split line style self. tableView. separatorStyle = UITableViewCellSeparatorStyleNone;
- Data Source Method
// Number of cells-(NSInteger) numberOfSectionsInTableView :( UITableView *) tableView // tell tableView the number of rows in the section Group-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section // tell tableView what is displayed in each row (every row of tableView is UITableViewCell)-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath // tell tableView the header title text in the section Group-(NSString *) tableView :( UITableView *) tableView titleForHeaderInSection :( NSInteger) section // tell tableView the ending title text of the section Group-(NSString *) tableView :( UITableView *) tableView titleForFooterInSection :( NSInteger) section // return the index title of each Group-(NSArray *) sectionIndexTitlesForTableView :( UITableView *) tableView // return the height of each cell-(CGFloat) tableView :( UITableView *) tableView heightForRowAtIndexPath :( NSIndexPath *) indexPath // delete data-(void) tableView :( UITableView *) tableView commitEditingStyle :( partial) editingStyle forRowAtIndexPath :( NSIndexPath *) indexPath ;//
- Proxy Method
// As long as this method is implemented, the button function appears on the left slide (once N buttons appear on the left slide, tableView enters the editing mode, tableView. editing = YES)-(void) tableView :( UITableView *) tableView commitEditingStyle :( UITableViewCellEditingStyle) editingStyle forRowAtIndexPath :( NSIndexPath *) indexPath // button (NSArray *) displayed when the cell is left-sliding *) tableView :( UITableView *) tableView handler :( NSIndexPath *) indexPath {UITableViewRowAction * action0 = [comment rowActionWithStyle: comment title: @ "follow" handler: ^ (UITableViewRowAction * action, NSIndexPath * indexPath) {NSLog (@ "Click follow"); // detaches the button that appears on the left slide (exit edit mode) tableView. editing = NO;}]; UITableViewRowAction * action1 = [UITableViewRowAction rowActionWithStyle: deleting title: @ "delete" handler: ^ (UITableViewRowAction * action, NSIndexPath * indexPath) {[self. wineArray removeObjectAtIndex: indexPath. row]; [tableView deleteRowsAtIndexPaths: @ [indexPath] withRowAnimation: UITableViewRowAnimationAutomatic];}]; return @ [action1, action0];} // The agent method obtains the selected rows, row number-(void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath; // allows you to edit the selected row-(BOOL) tableView :( UITableView *) tableView canEditRowAtIndexPath :( NSIndexPath *) indexPath;