所以,我有這個問題,那應該是微不足道的。我有一個加載從廈門國際銀行的另一個視圖控制器視圖控制器。的UIViewController通過廈門國際銀行加載另一個視圖控制器,試圖訪問默認視圖導致崩潰
'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "Embedded" nib but the view outlet was not set.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010689134b __exceptionPreprocess + 171
的代碼片段,這是否看起來像這樣::試圖引用次要視圖控制器的視圖與崩潰
- (void)viewDidLoad {
[super viewDidLoad];
// loads controller just fine.
EbeddedViewController *embedded = [[EbeddedViewController alloc] initWithNibName:@"Embedded" bundle:nil];
// KABOOM on line below
UIView *embeddedViewIs = embedded.view;
}
的EmbeddedViewController延伸的UIViewController,這是很普通的/純..
#import "EbeddedViewController.h"
@interface EbeddedViewController()
@property (nonatomic, strong) IBOutlet UILabel *embeddedLabel;
@end
@implementation EbeddedViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
這是很無聊和普通:
這是默認視圖 - 我嘗試添加一個IBOutlet,但它崩潰了。
的廈門國際銀行視圖控制器設置了自定義類正確:
我不知道爲什麼這種崩潰。如果你想嘗試這個小應用程序,請在這裏下載:
Link to a tiny two view controller app where this crash is demonstrated
嘗試訪問viewDidAppear方法的視圖。 Outlet尚未設置在viewDidLoad方法中。 –
謝謝,回覆!我曾嘗試把該代碼關鍵部分 - 在viewdidappear的廈門國際銀行的加載,以及事故發生完全相同的方式 - 同樣的事情。然後,我決定分家,他們 - 我把廈門國際銀行的加載在viewDidLoad中,並在訪問的viewdidappear視圖,它也應聲完全相同的方式... – geekyaleks