我使用 a 创建了一个选项菜单,UITableViewController
并且可以正确设置标签,但不能正确设置图像。
我尝试取出 switch 语句并使用基于正确值填充的数组,但[indexPath row]
也无法使其正常工作。
有任何想法吗?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier];
}
switch ([indexPath row]) {
case 0:
[[cell imageView] setImage:[UIImage imageNamed:@"42-photos.png"]];
[[cell textLabel] setText:@"Photos"];
break;
case 1:
[[cell imageView] setImage:[UIImage imageNamed:@"280-clapboard.png"]];
[[cell textLabel] setText:@"Videos"];
break;
case 2:
[[cell imageView] setImage:[UIImage imageNamed:@"42-info.png"]];
[[cell textLabel] setText:@"About"];
break;
default:
return cell;
break;
}
return cell;
}