有没有方法设置UITableViewCell.图片显示在单元格的右边而不是左边?或者我是否需要在布局的右边添加单独的UIImageView?
不需要,但是你可以简单给表格单元格添加作为辅助视图的图像视图来获得同样的效果。
图片显示在单元格的左边而不是左边?
这是给每个cell添加不同图片的方法,尝试一下。
// 自定义表视图单元格的外观
不需要,但是你可以简单给表格单元格添加作为辅助视图的图像视图来获得同样的效果。
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"foo.png"]];
cell.accessoryView = imageView;
[imageView release];
图片显示在单元格的左边而不是左边?
cell.imageView.image = [UIImage imageNamed:@“imageName”];
这是给每个cell添加不同图片的方法,尝试一下。
// 自定义表视图单元格的外观
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if(indexPath.row == 0)
{
cell.image = [UIImage imageNamed:@"image.png"];
}
else if (indexPath.row == 1)
{
cell.image = [UIImage imageNamed:@"image1.png"];
}