2012-04-28 69 views

回答

6

使用下面的代碼的陣列...

- (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; 
} 

希望,這將幫助你......

+0

thanx的幫助親愛的 – Toseef 2012-05-01 08:42:56

+0

如果它的幫助,接受答案不適合我而是其他。所以如果他們有類似的問題,他們可以選擇最好的解決方案它幫助你和堆棧溢出.. – Nit 2012-05-01 08:45:06

5

例如:

cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"image%i.png", indexPath.row]]; 

cell.imageView.image = (UIImage *)[yourArray objectAtIndex:indexPath.row]; 
+0

thanx幫助朋友 – Toseef 2012-05-01 08:36:31

5

您的搜索解決方案n爲這裏去這個鏈接How to add UIImage in the UITableView

- (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; 
    } 

的UITableView與圖像顯示像

enter image description here

-1
cell.imageView.image = [UIImage imageNamed:@"image.png"]; 
相關問題