为 tableView 注册笔尖名称 [英] Register nib name for tableView

查看:59
本文介绍了为 tableView 注册笔尖名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

static NSString *cellIdentifier = @"cell";
if (tableView ==tableview1) 
{
    ContactCustom *cell1=(ContactCustom *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];        
    if (cell1 == nil) 
    {
        [[NSBundle mainBundle] loadNibNamed:@"ContactCustom" owner:self options:nil];
        cell1 = contactCustom;
    }
}

在调用cellForRowAtIndex方法之前如何在viewDidLoad方法中注册nib名称?

How to register nib name in viewDidLoad method before calling cellForRowAtIndex method?

推荐答案

-(void)viewDidLoad
{
   [super viewDidLoad];
   [self.tableView registerNib:[UINib nibWithNibName:@"cell" bundle:nil] 
   forCellReuseIdentifier:@"cell"];
}

这篇关于为 tableView 注册笔尖名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆