December 2012
Intermediate to advanced
834 pages
27h
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]){staticNSString*MyCellIdentifier=@"SimpleCell";/* We will try to retrieve an existing cellwith the given identifier */result=[tableViewdequeueReusableCellWithIdentifier:MyCellIdentifier];if(result==nil){/* If a cell with the given identifier does notexist, we will create the cell with the identifierand hand it to the table view */result=[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:MyCellIdentifier];}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.myTableView.dataSource=self;self.myTableView ...
Read now
Unlock full access