我有一個UITableView,其方法爲cellForRowAtIndexPath
,如下所示,問題在於cellImage
僅在完全向上滾動(因此沒有行可見)然後釋放後出現。奇怪的是,我在另一個類中有相同的代碼用於單獨的表視圖,並且圖像顯示正常。有任何想法嗎?單元格圖像僅在滾動後出現
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryNone;
}
[cell.textLabel setText:[items objectAtIndex:indexPath.row]];
[cell.textLabel setFont:[UIFont fontWithName:@"Helvetica" size:15.0f]];
[cell.textLabel setTextColor:[UIColor whiteColor]];
[cell setBackgroundColor:[[UIColor alloc] initWithRed:117.0/255.0 green:118.0/255.0 blue:121.0/255.0 alpha:1.0]];
[self.tableView setBackgroundView:nil];
[self.tableView setBackgroundView:[[UIView alloc] init]];
[self.view setBackgroundColor:[[UIColor alloc] initWithRed:167.0/255.0 green:169.0/255.0 blue:172.0/255.0 alpha:1.0]];
UIImageView *cellImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]];
[cell addSubview:cellImage];
[cellImage setFrame:CGRectMake(0, 0, 26, 24)];
[cellImage setCenter:CGPointMake(cell.frame.size.width - 30, cell.frame.size.height/2)];
return cell;
}
不會問相關的,但爲什麼:[self.tableView setBackgroundView:無]。 [self.tableView setBackgroundView:[[UIView alloc] init]]; [self.view setBackgroundColor:[[UIColor alloc] initWithRed:167.0/255.0 green:169.0/255.0 blue:172.0/255.0 alpha:1.0]];在你的cellforrow委託方法中?它不建議在那裏 – 2012-08-09 11:47:22
爲什麼る加入cellImage細胞作爲默認的單元格有imgView u可以使用這樣cell.imgView.image = yourImage – 2012-08-09 11:49:29
如果u要顯示在單元格,然後單擊使用單元格的附件disclosureIndicator和刪除您的ImageView – 2012-08-09 11:53:02