October 2013
Intermediate to advanced
1053 pages
28h 7m
English
You want to grab users’ attention in a table view by displaying accessories and offer different ways to interact with each cell in your table view.
Use the accessoryType of
the UITableViewCell class, instances
of which you provide to your table view in its data source
object:
-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{UITableViewCell*result=nil;if([tableViewisEqual:self.myTableView]){result=[tableViewdequeueReusableCellWithIdentifier:MyCellIdentifierforIndexPath:indexPath];result.textLabel.text=[NSStringstringWithFormat:@"Section %ld, Cell %ld",(long)indexPath.section,(long)indexPath.row];result.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;}returnresult;}-(NSInteger)tableView:(UITableView*)tableViewnumberOfRowsInSection:(NSInteger)section{return10;}-(void)viewDidLoad{[superviewDidLoad];self.myTableView=[[UITableViewalloc]initWithFrame:self.view.boundsstyle:UITableViewStylePlain];[self.myTableViewregisterClass:[UITableViewCellclass]forCellReuseIdentifier:MyCellIdentifier];self.myTableView.dataSource=self;self.myTableView.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;[self.viewaddSubview:self.myTableView];}
You can assign any of the values defined in the UITableViewCellAccessoryType enumeration to
the accessoryType property of an ...
Read now
Unlock full access