2013-03-04 41 views
1

我有一個UIImageView的問題我設置內部tableview:cellForRowAtIndexPath:由於某種原因,當UITableView加載視圖中的底部單元一半劑量沒有一個圖像加載到UIImageView像UITableViewCells的其餘部分,但是一旦我滾動然後它就會自行出來..但是一旦這樣做,頂部UItableViewCell然後將其圖像!直到我滾動回到全景。UIImageView不加載在UITableViewCell直到滾動

我所做的是在接口生成器中創建UITableViewCell,並且我有一個空白的UIImageView,然後設置UIImage我將放置在ViewDidLoad中的UIImageView中,然後在tableview中:CellForRowAtIndexPath:我設置它然後返回單元格。

繼承人的代碼

//.m 
- (void)viewDidLoad 
{ 
//.. 
storageCalcIconImage = [UIImage imageNamed:@"CALC.png"]; 
} 

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

    SeriesSearchResultItem *myObj = [[SeriesSearchResultItem alloc] init]; 


    if (indexPath.section == 0) { 

     //call obj array with all of the values from my sorting algorithum 
     myObj = (SeriesSearchResultItem*)[dataArrayOfObjects objectAtIndex:indexPath.row]; 
//.. assinging storageCalcIconImage inside if statment 
firstSpaceImage.image = storageCalcIconImage; 
//.. 
} 
    return cell; 
} 

有很多在發生的tableView:的cellForRowAtIndexPath但我決定放棄該wasnt涉及到形象問題..東西希望你們能看到一個錯誤,我做我尚未...任何幫助將不勝感激。

回答

0

這是使用tableView中可重用單元格的預期結果。如果你想避免這種行爲,你應該爲你的tableView的每一行創建一個單元格,而不是使用dequeueReusableCellWithIdentifier。 如果您有很多要顯示的行,則會產生巨大的性能影響。

+0

如果您爲這些單元格顯示動態數量的tableviewcells和信息,如何爲每行創建一個單元格? – HurkNburkS 2013-03-04 21:44:04

+0

你的tableView通常顯示一個NSArray對象的內容。當你改變這個NSArray的內容時,你只需在你的tableView上調用'reloadData'來顯示刷新的數據。 'cellForRowAtIndexPath'就是在這裏向你的tableView指出如何在特定的indexPath處顯示一行。 – Kirualex 2013-03-04 21:55:02

相關問題