Reusable cell Creation in tableview...
when we want to load the custom tableviewcell in tableview with dequeueReusableCellWithIdentifier
fallow this code.
It is useful to load the customcell in the tableview,dequeueReusableCellWithIdentifier is used to load the same cell with different content.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"positionCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = @"Position";
cell.textLabel.textColor =[UIColor greenColor];
cell.detailTextLabel.text = [_positionCountArray objectAtIndex:indexPath.row];
cell.detailTextLabel.textColor = [UIColor redColor];
return cell;
}
No comments:
Post a Comment