开发者

iPad app crashes on loading nib only on device not in simulator

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.

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 contain开发者_高级运维s 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''

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];

In a larger context:

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

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.

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

Thanks in advance. Any help is greatly appreciated!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜