2016-02-10 56 views
0

我正在開發一個可可框架,它提供的託管應用程序的的UINavigationController在與定製單元一個UITableViewController自定義單元格XIB。負載從一個框架

我設法通過的UINavigationController與UIViewControllers作爲根視圖到託管應用程序,使用導航控制器的didLoad:

NSBundle* frameworkBundle = [NSBundle bundleForClass:[self class]]; 
ContactsListVC *v = [[ContactsListVC alloc] 
       initWithNibName:@"ContactsListVC" 
       bundle:frameworkBundle]; 

[self addChildViewController: v]; 

但我無法弄清楚如何定製單元加載到tableview中,給我一個錯誤:「無法出列與標識ContactCell細胞 - 必須註冊一個筆尖或一個類的標識符或連接故事板中的原型單元格「。

回答

0

我做到了。

在的UITableViewController的.M

-(void)viewDidLoad { 
    [super viewDidLoad]; 
    NSBundle *frameworkBundle = [NSBundle bundleForClass:[self class]]; 
    UINib *nib = [UINib nibWithNibName:CONTACTCELL bundle:frameworkBundle]; 
    [[self tableView] registerNib:nib forCellReuseIdentifier:CONTACTCELL]; 
    } 


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    ContactCell *cell = [tableView dequeueReusableCellWithIdentifier:CONTACTCELL forIndexPath:indexPath]; 
    //other stuff.... 
    return cell; 
    }