以我AppDelegate-> applicationWillFinishLaunching我裝載兩個視圖控制器與查看不顯示 「有時」 可可
NSViewController *v = [[MyCustomViewController alloc] initWithNibName:@"aNib" bundle:nil];
MyCustomViewController的initWithNibName:束:方法是自動生成的:
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
...
我添加他們在自定義視圖中的視圖:[theMainView addSubview:[v view]]
我不明白爲什麼有時(像十次中的一次)視圖被加載但不顯示。
編輯:
MyCustomViewController1 *v = [[MyCustomViewController1 alloc] initWithNibName:@"aNib" bundle:nil];
[themainview addSubview:[v view]];
MyCustomViewController2 *v2 = [[MyCustomViewController2 alloc] initWithNibName:@"aNib2" bundle:nil];
[themainview addSubview:[v2 view]];
self.view1 = [[themainview subviews] objectAtIndex:0];
self.view2 = [[themainview subviews] objectAtIndex:1];
[view2 setHidden:YES];
廠景和視圖2是在AppDelegate中
請問您的應用程序中使用垃圾回收?如果是這樣,你是否保持強烈的視圖控制器引用? – 2011-07-01 00:30:46