首页 新闻 会员 周边

tableviewcell的详解

0
[待解决问题]

今天在做项目时,遇到个问题。希望大神来说说原因。我在进行tableview的刷新时,刷新后没进入cell==nil这个判断,而是进入了cell != nil,求解释!如果是在缓存池中找到的话,那么理由呢?reloaddata之后不是应该进入cell == nil这个判断吗?求大神解释!!

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"cell";
    
    if (indexPath.section == 0) {
        FirstPersonalInformationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[FirstPersonalInformationTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            cell.firstLabel.text = self.firstNameArr[indexPath.row];
            if (indexPath.row == 0) {
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                cell.iconImage.image = [UIImage imageNamed:@"userImage.png"];
            }else if (indexPath.row == 1){
                cell.secondLabel.text = [[[PreferenceData GetToPreferencePathDic:DIC WithGetKey:@"loginDic"] objectForKey:@"username"] stringByAppendingString:@".hart"];
            }else if (indexPath.row == 2){
                cell.fifthLabel.text = @"第二行";
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            }else if (indexPath.row == 3){
                
                NSLog(@"%@", self.initialNationalityName);
                
                cell.fifthLabel.text = self.initialNationalityName;
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            }else if (indexPath.row == 4){
                cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                cell.QrCodeImage.image = [UIImage imageNamed:@"twoCode.png"];
            }
        }
        return cell;

以上就是我写的cellforrow代码。

卖身的小男孩的主页 卖身的小男孩 | 菜鸟二级 | 园豆:204
提问于:2016-03-08 16:44
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册