Tig*_*rry 2 xcode objective-c xib nib ipad
我知道之前已经问过这个问题,我花了很多时间跟踪各个主题的建议,不仅仅是在这个网站上,而是无济于事.
我正在为iPad开发一个包含多个视图的应用程序.这些视图中的每一个都包含一个UITableView.一些TableView单元格包含使用UITableViewCell实现的自定义单元格.现在的问题是我可以在iPad模拟器上运行我的应用程序而不会在实际设备上运行.在设备上 - 一旦我尝试访问包含该问题的自定义UITableViewCell的视图,它就会崩溃并显示以下消息:
2011-08-03 20:37:13.849 myApp[658:707] Creating cell: LabledTextFieldCell.xib
2011-08-03 20:37:13.866 myApp[658:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/B9A24738-FA19-4A54-8CE5-813B48E6871E/iCockpit-Client.app> (loaded)' with name 'LabledTextFieldCell.xib''
Run Code Online (Sandbox Code Playgroud)
我检查并重新检查,一切似乎都完好无损.该文件存在 - 在Xcode中以及物理上在文件系统中,并且在代码中以正确的名称引用它.
这是崩溃发生的代码行:
[[NSBundle mainBundle] loadNibNamed:MyIdentifier owner:self options:nil];
Run Code Online (Sandbox Code Playgroud)
在更大的背景下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
int curRow = indexPath.row;
int i = 0;
if (indexPath.section > 0) {
while (i < indexPath.section) {
curRow = curRow + [self sectionSize:i];
i++;
}
}
UITableViewCell *cellRet;
if (indexPath.section == 1) {
// code
} else if (indexPath.section == 2) {
// ...
} else if (indexPath.section == 3) {
static NSString *MyIdentifier = @"LabledSwitchCell";
NSLog(@"Creating cell: %@", MyIdentifier);
cellRet = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cellRet == nil) {
// CRASHES
// -------
[[NSBundle mainBundle] loadNibNamed:MyIdentifier owner:self options:nil];
// -------
cellRet = self.cell;
self.cell = nil;
}
// more code...
}
Run Code Online (Sandbox Code Playgroud)
值得注意的是:nib最初是通过File - > New - > New File ...,Cocoa Touch - > UIViewController子类添加的,它提供了三个文件 - MyClassViewController.m,MyClassViewController.h和MyClassViewController.xib.我已经将MyClassViewController.xib(在我的实际情况下为LabledTextfieldViewController.xib)重命名为MyClassView.xib(LabledTextfieldView.xib),这对我来说更合乎逻辑.
如上所述,应用程序在模拟器中工作正常,问题只发生在实际设备上.
我的Xcode版本是最新的Xcode 4.1(Build 4B110).
提前致谢.任何帮助是极大的赞赏!
| 归档时间: |
|
| 查看次数: |
894 次 |
| 最近记录: |