【发布时间】: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