2012-07-18 48 views
-2

是否有可能從web服務器爲表格視圖的每個說出的第5行提取圖像,而不會影響cellforrowatindexpath方法的正常運行?謝謝在表格視圖單元格中交替的外觀和感覺

+1

如果你的意思是問你是否可以在運行時下載的圖像,每'表的nth'行無負載造成的停頓,你將需要預先緩存這些圖像,因爲移動設備上的下載速度最多不穩定 – 2012-07-18 17:29:36

回答

2

示例代碼:

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

    // Here is the magic. 
    if (!indexPath.row % 5 == 0) 
    { 
     // Do your usual code 
    } 
    else 
    { 
     // Do alternate code (loading background image) 
    } 
    return cell; 
} 
+0

奇妙 - 感謝您的幫助盧克 – Alan 2012-07-18 20:23:57

2

檢查tableView:cellForRowAtIndexPath:如果indexPath.row可以被5整除,並且如果真(如其他背景圖像,......)不同則對待單元格。

+0

謝謝 - 你能告訴我該怎麼做嗎? – Alan 2012-07-18 19:39:42