【问题标题】:UITableView issue in iPad?iPad中的UITableView问题?
【发布时间】:2013-02-09 10:46:24
【问题描述】:

我正在使用 iPad 应用程序。我正在使用 UITableView 创建一个表格并在每个单元格中插入 2 个 UIImageViews。我尝试在UIImageViews 中设置图像,但索引路径值从 0、1、2、3、4 等开始...

每个UIImageView 在第一个单元格中都有相同的图像。如何解决这个问题?

例子:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // ImageArray have 5images;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{


    return [ImageArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    imgView1.image = [imageArray objectAtIndex:indexPath.row]; 
    imgView2.image = [imageArray objectAtIndex:indexPath.row]; 
 }

【问题讨论】:

  • 你在哪里设置 UIImageView ,我的意思是它设置为 cell.contentView ???
  • 你想在输出中显示吗?
  • [Imagearray count] = 5,然后我添加到每个 uiimageview img1.image = [imagearray objectatindex:indexpath.row]; img2.image = [imagearray objectatindex:indexpath.row];
  • iPatel - 是的,我已经设置了 cell.contentview add subview:img1

标签: ios ipad uitableview xcode4.3


【解决方案1】:

格式化代码后,很明显您将数组中的相同图像分配给两个图像视图中的每一个。您将需要一个具有双倍成员数量的 imageViewArray。

此外,您不应检查图像数组的计数,而应检查索引路径的 row

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-19
    • 2011-08-13
    • 1970-01-01
    • 1970-01-01
    • 2016-09-21
    • 2015-09-13
    相关资源
    最近更新 更多