【发布时间】:2012-08-25 20:29:20
【问题描述】:
我有一个 UIViewController,它有一个自定义的 init 方法,如下所示:
- (id)initWithFrame:(CGRect)frame_ customObject:(CustomObject *)object_ {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self = [super initWithNibName:@"ArtistViewController_iPad" bundle:nil];
} else {
self = [super initWithNibName:@"ArtistViewController" bundle:nil];
}
[self.view setFrame:frame_];
self.customObject = object_;
return self;
}
但是当 [self.view setFrame:frame_];被调用,它在日志中崩溃:
(空) libc++abi.dylib:终止调用抛出异常
这就是我从另一个 UIViewController 分配 UIViewController 的方式:
CGRect frame = self.view.frame;
artistViewController = [[ArtistViewController alloc] initWithFrame:frame customObject:anObject];
框架存在。自我存在于 [super initWithNibName:bundle];
但 self.view 似乎不存在。 nib 文件存在并且连接了它们的视图出口。
为什么会这样?
【问题讨论】:
-
在
-awakeFromNib中直到稍后才会从 nib 取消归档视图。
标签: ios uiviewcontroller