我想改變形象,當我點擊一個細胞,但它不工作圖像不會被調用的Objective-C
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [feedsTableView cellForRowAtIndexPath:indexPath];
UILabel *title = (UILabel *)[cell.contentView viewWithTag:0011];
UIImage *image = (UIImage *)[cell.contentView viewWithTag:0017];
image = [UIImage imageNamed:@"reload.png"];
title.text = @"test";
cellClicked = YES;
[feedsTableView beginUpdates];
[feedsTableView endUpdates];
[feedsTableView deselectRowAtIndexPath:indexPath animated:YES];
}
標題但是變化。
我的圖像如何添加到表格中。
CGRect imageFrame = CGRectMake(0, 0, 120, 90);
customImage.tag = 0017;
self.customImage = [[UIImageView alloc] initWithFrame:imageFrame];
[cell.contentView addSubview:self.customImage];
雖然這是真的,但只要您繼續使用'0011'作爲標籤並使用'0011'來獲得帶有該標籤的視圖,就不會產生影響。 – Jasarien
@Jasarien IB是否遵循相同的約定(假設這是標籤設置的地方)? – trojanfoe
這是另一個問題......它取決於IB是否將字段中的內容字面上看作整數,或者將其解析爲整數格式(從而剝離前導零)。將不得不測試。無論如何,這個問題表明標籤在代碼中被設置爲'0017'。 – Jasarien