2017-04-04 131 views
0

我还没有能够将Nib上传到我的表格视图,这个问题与我正在处理的其他应用程序发生时一样,尽管我确实有一些NIb文件可以正常工作。我甚至重新安装Xcode试图解决这个问题。我登记我的笔尖如下无法在包中加载Nib

let test = "test" 

let cellNib = UINib(nibName: test, bundle: nil) 
tableView.register(cellNib, forCellReuseIdentifier: test) 

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCell(withIdentifier: test, for:indexPath) as! testCell //after this function is called I get a crash 
    return cell 
} 

这是消息我从碰撞获得的一部分,我不知道是否有用。

'NSInternalInconsistencyException',原因: '在束无法加载NIB: '一个NSBundle(加载)' 名为 '测试'' ***第一掷调用堆栈: ( 0的CoreFoundation 0x000000010afdab0b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x0000000107b98141 objc_exception_throw + 48 2的CoreFoundation 0x000000010b043625 + [NSException提高:格式:] + 197 3的UIKit 0x0000000108b59b24 - [UINib instantiateWithOwner:选择:] + 501 4的UIKit 0x00000001088ac567 - [UITableView的_dequeueReusableViewOfType:withIdentifier:] + 402 5 UIKit 0x00000001088aca4b - [UITableView dequeueReusableCellWithIdentifier :forIndexPath:] + 71 6 Chaol 0x000000010759ebe9 _TFC5Chaol23QuestionsViewController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 153

我的.xib文件出现在拷贝束资源。

回答

1

也许nib文件没有添加到您的目标。 尝试这些步骤:

  1. 在项目>目标>构建阶段

    扩大复制包资源

    点击+按钮并添加所需的NIB文件。

    用Shift + Cmd + K清理你的版本,然后运行。

  2. 在你的.xib文件

    点击文件督察

    在目标籍部分,选择要使用

  3. 此外,仔细检查你的笔尖的名字拼写的目标。

+0

我绝对试过这样,它没有工作。我现在已经编程创建了一切。 –

相关问题