我用核心數據中的數據加載tableview。 它獲取文本加載。 每個單元格都有一個uiimageview。當表調用cellForRow:
它要麼設置圖像隱藏或不隱藏,(這取決於核心數據說,它應該是。)UITableView單元格給出了錯誤的信息
代碼:
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath{
static NSString * identifier = @"identifier";
self.cell = [tableView dequeueReusableCellWithIdentifier:identifier];
HuntingRifleGuns *handguns = [self.tableArray objectAtIndex:indexPath.row];
NSString *brandModel = [[handguns.brand stringByAppendingString:@" "] stringByAppendingString:handguns.model];
self.cell.mainLabel.text = brandModel;
self.cell.nicknameLabel.text = handguns.nickname;
//Right below me, is where is set the imageView to hidden, or not hidden.
self.cell.alert.hidden = handguns.showBadge.boolValue;
self.cell.alert.image = [UIImage imageNamed:@"tvicon.png"];
return self.cell;
}
我的問題是:如果我有1在桌子視圖上的單元格,它的工作原理非常完美,但是如果我在桌子上有更多的單元格,它就會起作用。
我要檢查,看看是否單元格的形象被隱藏,當它被刪除:
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
if (!self.cell.alert.isHidden) {
NSLog(@"showing");
}
else{
NSLog(@"Not showing");
}
.........
但是,當它的測試中,它不總是做正確的事情。它只是隨機打印出showing
或not showing
。我知道它是否應該顯示,因爲它顯示在單元格上的圖像。這可能是什麼原因? 只是一個側面說明,用戶可以設置圖像隱藏或不隱藏在不同的意見,但tableview總是顯示正確的數據,這意味着它顯示圖像正確可見或隱藏,只是當我測試它,它doesnt總是工作。
感謝您的幫助!