iOS应用程序 - 无法在捆绑中加载NIB

时间:2014-07-25 16:21:10

标签: ios objective-c nib

我有一个通用iOS应用程序,iPad版本使用名为PerformancePair.xib的界面,我按以下方式加载:

_pairView = [[[NSBundle mainBundle] loadNibNamed:@"performPair" owner:self options:nil] objectAtIndex:0];

执行该行时,我收到以下错误:

       2014-07-25 12:18:17.432 R2Lm[48976:60b] *** Terminating app due to uncaught exception
        'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 
        'NSBundle </Users/Me/Library/Application Support/iPhone Simulator/7.1-64/Applications/698D6EC4-2150-492B-9935-96B56FF95AE2/R2Lm.app> (loaded)' 
         with name 'performPair''
            *** First throw call stack:
            (
                0   CoreFoundation                      0x0000000101e95495 __exceptionPreprocess + 165
                1   libobjc.A.dylib                     0x000000010199599e objc_exception_throw + 43
                2   CoreFoundation                      0x0000000101e952ad +[NSException raise:format:] + 205
                3   UIKit                               0x000000010079d742 -[UINib instantiateWithOwner:options:] + 775
            ...MORE STACK TRACE HERE....

您可以看到我已使用"performPair"正确命名RestorationID,并且我的PerformancePair.xib处于构建阶段。

enter image description here

我还缺少什么?

1 个答案:

答案 0 :(得分:3)

您必须在loadNibNamed:中使用nib文件的名称。

_pairView = [[[NSBundle mainBundle] loadNibNamed:@"PerformancePair" owner:self options:nil] objectAtIndex:0];