【发布时间】:2017-04-04 00:08:59
【问题描述】:
我无法将 Nib 上传到我的表格视图,这个问题也发生在我正在处理的其他应用程序中,即使我确实有一些 NIb 的文件工作得很好。我什至重新安装 Xcode 试图解决这个问题。我按如下方式注册我的笔尖
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(已加载)',名称为 'tests'' *** 首先抛出调用堆栈: ( 0 核心基础 0x000000010afdab0b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x0000000107b98141 objc_exception_throw + 48 2 核心基础 0x000000010b043625 + [NSException raise:format:] + 197 3 UIKit 0x0000000108b59b24-[UINib 实例化WithOwner:选项:] + 501 4 UIKit 0x00000001088ac567-[UITableView _dequeueReusableViewOfType:withIdentifier:] + 402 5 UIKit 0x00000001088aca4b-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 71 6 Chaol 0x000000010759ebe9 _TFC5Chaol23QuestionsViewController9tableViewfTCSo11UITableView12cellForRowAtV10Foundation9IndexPath_CSo15UITableViewCell + 153
我的 .XIB 文件出现在副本包资源中。
【问题讨论】: