2 Jan 2017

Reusable cell (dequeReusablecellwithIdentifier) Creation in tableview


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

Recent Posts

Codable demo

Link: https://www.dropbox.com/s/kw7c1kgv1628bh7/codableDemo.zip?dl=0