2012-11-01 65 views
0

我有三個不同的自定義cells.Each表視圖會從三個不同的細胞classes.`加載Tableview滾動並不那麼流暢?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier1 = @"CellIdentifier"; 
    static NSString *CellIdentifier2 = @"Cell"; 
    static NSString *CellIdentifier3 = @"Cell"; 
    if (indexPath.section == 0) 
    { 
     CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1]; 

     if (cell == nil) 
     { 
      cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier1] autorelease]; 
     } 
     [email protected]"dhhg"; 
     [email protected]"shdhsjdj"; 
    [email protected]"sdhhhfhjhfj"; 

     cell.myImageView.image=[UIImage imageNamed:@"sd.png"]; 
     [email protected]"hhhf"; 

     return cell; 

    } 
    else 
    { 


     Customcellwithimage *cell = (Customcellwithimage *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2]; 

     if (cell == nil) 
     { 
      cell = [[[Customcellwithimage alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier2] autorelease]; 
     } 
     [email protected]"sdhkhks"; 
     [email protected]"sdhjkhkshd"; 
     [email protected]"sdsdsd"; 

     cell.myImageView1.image=[UIImage imageNamed:@"shdjhjhs"]; 
     [email protected]"sjdh"; 
     cell.bannerview1.image=[UIImage imageNamed:@"dshjs"]; 

     return cell; 
    } 

return Nil; 

} 

'。這是我對design.Can任何代碼幫助我在我要去的地方錯誤?

+0

當取消註釋圖像的東西時,甚至會發生這種情況嗎? –

+0

它從我的自定義類中加載。單元格本身包含一個圖像。 –

+0

是的,所以當你取消處理圖像的所有代碼時,請檢查它是否仍然有問題,以便最終不加載圖像。基本上,這應該工作,你有證據表明你的圖像造成滯後。 –

回答

0

首先cellIdentifier2和cellIdentifier3與@「cell」具有相同的值。
您只包含2個條件,一個用於第零部分,第二個用於其他部分。
您還應該提及使用cellIdentifier3的條件。
你還沒有提到你有什麼問題,因爲你的代碼似乎沒有任何錯誤。
你想要什麼輸出?不同部分的不同細胞?

+1

no.i想要加載不同類型的響應的不同類型的響應,我從webservise.as獲得一個經驗,我已經做到了這一點。 –

+0

可能存在加載具有較大分辨率的圖像的問題,這可能不會在表格視圖單元格中需要。因此,您可以在服務器或項目中放置較小的圖像。但如果你不知道你會收到的圖像的大小,那麼你可以嘗試調整圖像的大小。 –

0

檢查你的圖像尺寸。 如果圖像尺寸較大,表格視圖將不平滑

+0

我們如何調整圖像大小? –

+0

你應該準備你的圖像以適合你的圖像尺寸。在添加到您的項目之前,請使用 。 ex。正常顯示爲50x50,視網膜顯示爲100x100 – CodeBanBan