替换initWithNibName:bundle:调用以使用故事板

时间:2014-06-27 14:05:14

标签: ios objective-c cocoa-touch uistoryboard nib

此代码使用xib,运行正常,没有任何错误或异常。

- (id)initWithPageNumber:(int)page
{
    self = [super initWithNibName:@"MyViewController" bundle:nil];
    if (self !=nil)
    {
        pageNumber = page;
        NSLog(@"=====%@",pageNumberLabel);
    }
    return self;
}

然后我使用故事板尝试了这段代码,我得到了一个异常

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/Balu/Library/Application Support/iPhone Simulator/7.0.3/Applications/973E52E9-0923-49A0-B4A6-212BC5F367CD/scrollpages.app> (loaded)' with name 'MyViewController''

有人可以向我解释如何编写这行代码以用于故事板吗?

self = [super initWithNibName:@"MyViewController" bundle:nil];

0 个答案:

没有答案