私が解決しようとしている問題:
UInavigatioControllerをrootViewControllerとして持つプロジェクトで、第5章(C05 / 06- https://github.com/erica/iOS-5-Cookbook.gitのページをスクラブ)で第05章の例06 BookControllerを使用しましたが、使用していませんランドスケープモードで正しく起動します。デバイスを縦向きに回転させて横向きに戻すと、デバイスが機能し始めます。
バグを表示するには、main.cのテストベッドデリゲートの例を次のように変更します。
#pragma mark Application Setup
@interface TestBedAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
}
@end
@implementation TestBedAppDelegate
TestBedViewController *tbvc;
UINavigationController *navigationController;
- (void) pushBookController: (UIGestureRecognizer *) recognizer
{
[navigationController pushViewController:tbvc animated:YES];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
tbvc = [[TestBedViewController alloc] init];
UIViewController *start = [tbvc controllerWithColor:[UIColor whiteColor] withName:@"white"];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushBookController:)];
[start.view addGestureRecognizer:tap];
navigationController = [[UINavigationController alloc] initWithRootViewController:start];
window.rootViewController = navigationController;
[window makeKeyAndVisible];
return YES;
}
@end
私のアプリケーションは横向きで起動するので、問題はブックコントローラーが起動時に横向きモードを認識しないことです(起動後に回転すると機能します)。それを試してみてください。
開始時にランドスケープを認識するには、BookControllerで次のメソッドに置き換えます
// Entry point for external move request
- (void) moveToPage: (uint) requestedPage
{
//[self fetchControllersForPage:requestedPage orientation:(UIInterfaceOrientation)[UIDevice currentDevice].orientation];
[self fetchControllersForPage:requestedPage orientation:self.interfaceOrientation];
}
そして、以下を追加します。
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {return YES;}
ここで問題となるのはBookController
、最初は表示されないことですが、回転させると機能し始めます。