Reputation: 2216
I just added a IBOutlet
to my UIImageView
in my Storyboard and now my Custom TableViewCell
does not work anymore.
2012-08-13 13:30:28.052 Project[6189:fb03] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TableViewController 0x808ab80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imageView.'
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
static NSString *CellNib = @"CustomCell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellNib owner:self options:nil];
cell = (CustomCell *)[nib objectAtIndex:0];
}
...
}
Any Advice?
Upvotes: 0
Views: 288
Reputation: 2783
This is my app look. I use Dynamic Prototyping Table and custom cells.
My storyboard is like below.
The point is that you should set tag of image view as below.
Don't forget to set the cell identifier same with that in code. And the code is below:
UIImageView *imageView = (UIImageView *)[cell viewWithTag:5];
imageView.image = [UIImage imageNamed:@"foo.jpg"];
Upvotes: 1