2012-07-18 50 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