私が解決しようとしている問題:BookController風景モードでは正常に起動しない
私は(C05/06-スクラブページの第5章の章05例06 BookControllerを使用in https://github.com/erica/iOS-5-Cookbook.git)、UInavigatioControllerをrootViewControllerとして持つプロジェクトでは、横向きモードで正しく起動しません。デバイスのポートレートを回転させて風景に戻すと、作業が始まります。
#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
(私のアプリケーションは、風景を開始し、その問題は本コントローラは起動時にランドスケープモードを認識しないということである:バグは以下にmain.cの例のテストベッドのデリゲートを変更表示するには
あなたが起動した後に回転するなら、それはうまくいくでしょう)。それを試してみてください。以下の方法
// Entry point for external move request
- (void) moveToPage: (uint) requestedPage
{
//[self fetchControllersForPage:requestedPage orientation:(UIInterfaceOrientation)[UIDevice currentDevice].orientation];
[self fetchControllersForPage:requestedPage orientation:self.interfaceOrientation];
}
、開始時にBookControllerで代用風景を認識し、以下を追加するには
:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {return YES;}
さて問題はBookController
は、開始時に表示されますが、再び場合はいないということですそれを回転させると作業が始まります。