我有這樣的級聯:iPhone - self.view是initWithNibName子零,而viewDidLoad中不叫
某處在應用
- (void) go
{
MyCustomViewController* controller = [[MyCustomViewController alloc] init];
controller.delegate = self;
[controller run];
}
在MyCustomViewController
- (id) init
{
// there is an if statement here in real to choose another XIB if needed
// but I only display here the code that is called in my tests
self = [super initWithNibName:@"MyXIB" bundle:nil];
if (!self) return nil;
self.delegate = nil;
return self;
}
- (void) run
{
// do things with self.view
}
MyCustomViewController繼承GenericWindowController
在GenericWindowController
/*- (id) initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
if (!(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) return nil;
self.view.userInteractionEnabled = NO; // THE APP CRASHES HERE ! self.view is nil
...
return self;
}*/
// METHOD created following first answers : NOT CALLED
- (void) viewDidLoad
{
self.view.userInteractionEnabled = NO;
// and many other things done with self.view
}
MyXIB 有文件的所有者設置爲MyCustomViewController和視圖連接。
包含所有文件並將其檢入到項目中。
GenericWindowController被設計來製作一些標準的東西。
MyCustomViewController將這些東西擴展到MyXIB中設計的自定義視圖。
爲什麼self.view在GenericWindowController中爲零?
爲什麼viewDidLoad
不叫?
????請解釋 – 2014-12-07 03:36:35
@TylerPfaff:我的應用程序已本地化,並且其中一個本地化文件(即使由於設備配置而未使用)丟失。我只是把它加回來,沒有更多的問題。 – Oliver 2014-12-07 11:09:35