zoukankan      html  css  js  c++  java
  • 禁用UITableViewCell 重用机制

    有时候不想让Cell重用,怎么办勒。接下来介绍两种方法
    
    方法一
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  
    {  
        static NSString *CellIdentifier = @"Cell";  
        // UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; //改为以下的方法  
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; //根据indexPath准确地取出一行,而不是从cell重用队列中取出  
        if (cell == nil) {  
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];  
        }  
         //...其他代码                                
    }  
    
    方法二:(自定义Cell)
    CustomCell *cell = nil;
            if (cell == nil) {
                cell = [[CustomCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndetifier];
            }
            return cell;
  • 相关阅读:
    Nginx 跨域配置支持
    数据结构与算法分析
    数据结构与算法分析
    数据结构与算法分析
    Bash shell
    Bash shell
    HHUOJ 1040
    HHUOJ 1114
    HDUOJ 1171
    HDUOJ 1428
  • 原文地址:https://www.cnblogs.com/joesen/p/3937277.html
Copyright © 2011-2022 走看看