使用以下代码......
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
/* Initialise the cell */
static NSString *CellIdentifier = @"MyTableViewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
/* Configure the cell */
NSString *cellImageName = [[self cellImageNames] objectAtIndex:[indexPath row]];//cellImageNames ism image names array where
UIImage *cellImage = [UIImage cellImageName];
[[cell imageView] setImage:cellIcon];
// Other cell configuration code...
return cell;
}
Run Code Online (Sandbox Code Playgroud)
希望对你有帮助...
例如:
cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image%i.png", indexPath.row]];
Run Code Online (Sandbox Code Playgroud)
要么
cell.imageView.image = (UIImage *)[yourArray objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)
您的解决方案是在这里链接 如何在UITableView中添加UIImage
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
MyIdentifier = @"TableView";
MainView *cell = (MainView *)[tableView dequeueReusableCellWithIdentifier: MyIdentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"MainView" owner:self options:nil];
cell = tableCell;
}
[cell LabelText:[arryList objectAtIndex:indexPath.row]];
[cell ProductImage:[imagesList objectAtIndex:indexPath.row]];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
Uitableview与图像显示像

| 归档时间: |
|
| 查看次数: |
897 次 |
| 最近记录: |