现在的位置: 首页 > 综合 > 正文

iOS:从xib文件中加载Cell

2014年09月05日 ⁄ 综合 ⁄ 共 441字 ⁄ 字号 评论关闭

    static NSString *CellIdentifier = @"Cell";
    Cell *cell = (Cell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (!cell) {
        
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([Cell class])
                                             owner:self
                                           options:nil] objectAtIndex:0];
        //cell = [[[Cell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.titleLabel.text = [self.dataList objectAtIndex:indexPath.row];return cell;

如果需要从xib文件中加载cell,可采用上述方法。

抱歉!评论已关闭.