2
我的拆分視圖控制器代碼:shouldAutorotateToInterfaceOrientation被多次調用 - 這是正常的嗎?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
LeftViewController *hvc = [[[LeftViewController alloc] initWithNibName:nil bundle:nil] autorelease];
DetailViewController *dvc = [[[DetailViewController alloc] initWithNibName:nil bundle:nil] autorelease];
UINavigationController *rootNav = [[[UINavigationController alloc] initWithRootViewController:hvc] autorelease];
UINavigationController *detailNav = [[[UINavigationController alloc] initWithRootViewController:dvc] autorelease];
UISplitViewController *svc= [[[UISplitViewController alloc] init] autorelease];
[svc setViewControllers:[NSArray arrayWithObjects:rootNav, detailNav, nil]];
svc.delegate = dvc;
[window setRootViewController:svc];
[self.window makeKeyAndVisible];
return YES;
}
DetailViewController.m和LeftViewController.m都包含
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
NSLog(@"should rotate asked to detailviewcontroller");
return YES;
}
在iPad模擬器,我可以看到這些多次調用shouldAutorotateToInterfaceOrientation
當應用程序只是獲取推出
should rotate asked to detailviewcontroller
should rotate asked to leftviewcontroller
should rotate asked to leftviewcontroller
should rotate asked to detailviewcontroller
...
should rotate asked to leftviewcontroller // these two lines
should rotate asked to detailviewcontroller // are repeated 13 times
...
should rotate asked to leftviewcontroller
should rotate asked to detailviewcontroller
背後的原因是什麼?我必須提到我不改變模擬器的方向
據我所知,外部實體可以調用'shouldAutorotateToInterfaceOrientation'然而他們想多次。但超過15倍?觸發器是什麼?只是想到如果你看到一些明顯錯誤的地方,你們都要仔細檢查。 –