dequeueReusableCellWithIdentifier forIndexPath
I have a custom/sub-classed UITableViewCell using NSLayoutConstraints. The
left most UIImageView may or may not be populated with an image, and if
not, the objects to right of this field will naturally shift to the left.
Works well within the custom UITableViewCell, however I'll be populating
the content with my custom UITableViewController. Unfortunately, following
code will populate every row cell.dispatchedView with an image -- though
I've trapped to not populate rows with anything.
This has something to do with the dequeueReusableCellWithIdentifier. Ideas?
static NSString *CellIdentifier = @"CellIdentifier";
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView registerClass:[NXGActiveUnitsCell class]
forCellReuseIdentifier:CellIdentifier];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath*)indexPath {
NSDictionary *item = [self.model.dataSource objectAtIndex:indexPath.row];
NXGActiveUnitsCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
if([[[item objectForKey:@"cfs_no"] clean] length] > 0) {
cell.dispatchedView.image = [UIImage imageNamed:@"p.png"];
NSLog(@">>>%@",[item objectForKey:@"cfs_no"] );
} else {
NSLog(@">>> i got nothing so I should not touch this row...");
}
cell.departmentIconView.image = [UIImage imageNamed:@"f.png"];
cell.unitLabel.text = [item valueForKey:@"unit_id"];
return cell;
}
No comments:
Post a Comment