私のアプリケーションは、UIWindow. self.windowビュー コントローラーをinにプログラムで追加しますapplication:didFinishLaunchingWithOptions:。
myViewController = [[UIViewController alloc] init:...];
...
[self.window addSubview:myViewController.view];
[self.window makeKeyAndVisible];
同時に、バックグラウンド プロセスを開始します。
[NSThread detachNewThreadSelector:@selector(startupOperations) toTarget:self withObject:nil];
次のstartupOperationsような外観:
NSAutoreleasePool *threadPool = [[NSAutoreleasePool alloc] init];
// Load data
...
// When your done, call method on the main thread
[self performSelectorOnMainThread:@selector(showMainViewController) withObject:nil waitUntilDone:false];
// Release autorelease pool
[threadPool release];
showMainViewControllermyViewController を削除し、 を作成しUITabBarControllerてウィンドウのメイン ビューとして設定します。
[self.myViewController.view removeFromSuperview];
self.myViewController = nil;
tabBarController = [[UITabBarController alloc] init];
...
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
質問:
すべてのビュー コントローラが に対して YES を返していshouldAutorotateToInterfaceOrientation:ます。回転は正常に機能しますmyViewControllerが、 が表示されるとすぐtabBarControllerに回転が停止し、インターフェイスが縦向きに表示されます。この動作の背後にある理由は何ですか?
また、iOS 4.x では、UIWindow に rootViewController プロパティがあります。このプロパティの役割は何ですか? 新しいテンプレートでは、rootViewController代わりに[self.window addSubview:...]. 何故ですか?