iPad应用程序仅在未在模拟器中的设备上加载笔尖时崩溃 [英] iPad app crashes on loading nib only on device not in simulator

查看:88
本文介绍了iPad应用程序仅在未在模拟器中的设备上加载笔尖时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题以前曾被问过,我花了很多时间遵循各个主题中的建议,不仅是在此站点上,而且无济于事.

I know this question has been asked before and I spent a lot of time following the suggestions in various threads, not just on this site, but to no avail.

我正在为iPad开发一个包含多个视图的应用程序.这些视图中的每个视图都包含一个UITableView.一些TableView单元格包含使用UITableViewCell实现的自定义单元格.现在的问题是,我可以在iPad Simulator上运行我的应用程序,而在实际设备上没有问题.在设备上-一旦我尝试访问包含有问题的自定义UITableViewCell的视图,它就会崩溃并显示以下消息:

I'm developing an app for the iPad which consists of multiple views. Each one of these views contains a UITableView. Some of the TableView cells contain custom cells implemented with a UITableViewCell. The problem now is that I can run my app without problems on the iPad Simulator but not on the actual device. On the device - as soon as I try to access the view that contains that custom made UITableViewCell in question, it crashes with the following message:

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''

我已经检查并重新检查,一切似乎都井井有条.该文件存在-在Xcode中以及物理上都在文件系统中,并且在代码中以正确的名称进行引用.

I've checked and rechecked and everything seems to be in perfect order. The file exists - in Xcode as well as physically in the file system, and it's referenced in the code with its correct name.

以下是发生崩溃的代码行:

Here's the line of code on which the crash occurs:

[[NSBundle mainBundle] loadNibNamed:MyIdentifier owner:self options:nil];

在更大的范围内:

- (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...
}

可能值得注意的一点:笔尖最初是通过File-> New-> New File ...,Cocoa Touch-> UIViewController子类添加的,该子类提供了三个文件-MyClassViewController.m,MyClassViewController.h和MyClassViewController.xib .我已将MyClassViewController.xib(在我的实际情况下为LabledTextfieldViewController.xib)重命名为MyClassView.xib(LabledTextfieldView.xib),这对我来说似乎更合逻辑.

What might be worth noting: The nib has initially been added via File -> New -> New File..., Cocoa Touch -> UIViewController subclass which provides three files - MyClassViewController.m, MyClassViewController.h and MyClassViewController.xib. I have renamed the MyClassViewController.xib (in my actual case LabledTextfieldViewController.xib) to MyClassView.xib (LabledTextfieldView.xib) which appeared more logical to me.

如上所述,该应用程序可以在模拟器中正常运行,该问题仅在实际设备上出现.

As stated above, the app works fine in the simulator, the problem only occurs on the actual device.

我的Xcode版本是最新的Xcode 4.1(内部版本4B110).

My Xcode version is the latest Xcode 4.1 (Build 4B110).

先谢谢了.任何帮助,我们将不胜感激!

Thanks in advance. Any help is greatly appreciated!

推荐答案

检查您的NIB文件名的拼写,尤其是大写和小写.

Check the spelling of your NIB file name, particularly upper vs. lower case.

我相信模拟器文件系统不区分大小写,但实际设备是区分大小写的.

I believe the simulator file system isn't case sensitive, but the actual device is.

这篇关于iPad应用程序仅在未在模拟器中的设备上加载笔尖时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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