2012-08-13 70 views
0

我剛剛在我的故事板中添加IBOutlet到我的UIImageView,現在我的自定義TableViewCell不再有效。添加IBOutlet並自定義TableViewCell不再工作

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]; 
} 
... 
} 

有什麼建議嗎?

回答

1

這是我的應用程序外觀。我使用動態原型表和自定義單元格。

ss

我的故事板是像下面。

ss

的一點是,你應該設置如下圖像視標籤

ss

不要忘記設置相同與代碼中的小區標識。代碼如下:

UIImageView *imageView = (UIImageView *)[cell viewWithTag:5]; 
    imageView.image = [UIImage imageNamed:@"foo.jpg"]; 
+0

我的TableViewCell是自定義的。更高,10張標籤,4張照片。 UILabel Outlets正在工作。 UIImageView不是。這是我的問題。 – jussi 2012-08-13 12:34:21

+0

對不起,我誤解了你的情況。現在我展示了我的應用程序的一部分。我希望這對你有所幫助。 – weed 2012-08-13 12:37:50

+0

謝謝你的工作。 但我仍然不明白爲什麼我不能使用IBOutlet的UIImageView。這令人困惑 – jussi 2012-08-13 12:42:15