【发布时间】:2015-02-19 08:13:37
【问题描述】:
我已经创建了带有图像的表格视图,但图像不在正确的行中。我希望所有图像都在同一行 帮助我在模拟器中显示所有图像,因为我有超过 7 个案例处于切换状态。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
}
UIImageView *imageView=[cell.contentView viewWithTag:1];
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"wake up";
cell.detailTextLabel.text = @"wake up at 6 am and get ready for office";
cell.imageView.image=[UIImage imageNamed:@"wake-up-early-200.jpg"];
break;
case 1:
cell.textLabel.text = @"remainders";
cell.detailTextLabel.text = @"today is ajay's bday wish him ";
cell.imageView.image=[UIImage imageNamed:@"remainders.jpg"];
break;
case 2:
cell.textLabel.text = @"shopping";
cell.detailTextLabel.text = @"buy vegetables,fruits,dresses";
cell.imageView.image=[UIImage imageNamed:@"shopping.jpg"];
break;
case 3:
cell.textLabel.text=@"meeting";
cell.detailTextLabel.text=@"meeeting at lanuch pad by 4pm";
cell.imageView.image=[UIImage imageNamed:@"meeting.jpg"];
break;
case 4:
cell.textLabel.text=@"airport";
cell.detailTextLabel.text=@"bala is coming receive him on time";
cell.imageView.image=[UIImage imageNamed:@"airport.jpg"];
break;
case 5:
cell.textLabel.text=@"games";
cell.detailTextLabel.text=@"time for refresh";
cell.imageView.image=[UIImage imageNamed:@"games.jpg"];
break;
case 6:
cell.textLabel.text=@"lunch";
cell.detailTextLabel.text=@"go to lunch by 1pm";
cell.imageView.image=[UIImage imageNamed:@"lunch.jpg"];
break;
case 7:
cell.textLabel.text=@"coffee";
cell.detailTextLabel.text=@"go to ccd at 3pm";
cell.imageView.image=[UIImage imageNamed:@"coffee.jpg"];
case 8:
cell.textLabel.text=@"super market";
cell.detailTextLabel.text=@"buy household items";
cell.imageView.image=[UIImage imageNamed:@"market.jpg"];
break;
case 12:
cell.textLabel.text=@"iPhone app";
cell.detailTextLabel.text=@"iPhone app development training";
cell.imageView.image=[UIImage imageNamed:@"iphone.jpg"];
break;
case 11:
cell.textLabel.text=@"home";
cell.detailTextLabel.text=@"going to home by 11pm";
cell.imageView.image=[UIImage imageNamed:@"home.jpg"];
break;
default:
break;
}
//cell.textLabel.text = [todoitems objectAtIndex:indexPath.row];
//cell.detailTextLabel.text = @"This Is A Very Very Long String";
return cell;
}
【问题讨论】:
-
请正确格式化您的问题(使用 control+K 修复缩进问题,目前这很难阅读)
-
图片大小一样吗?没有透明框?
-
我明白了..我有很多案例,但只有 5 个案例被拿走并显示在模拟器中..为什么会这样??
-
请更好地解释您的需求,以便我可以帮助您
-
能否添加输出图片以便我们理解?
标签: ios uitableview