当应用程序处于横向模式(我打算强制)时,显示模式视图会导致父视图旋转到纵向模式。如果我将 shouldAutoRotateToInterfaceOrientation 的返回值设置为 NO,则父级不会旋转,但是模态会从侧面滑入并侧向显示。下面是显示模态的代码。
- (IBAction)loadExistingGame:(id)sender {
SavedGamesTableViewController *savedGames = [[SavedGamesTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
savedGames.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:savedGames animated:YES];
[savedGames release];
}
根据请求,这里是 SavedGamesTableViewController 的 shouldAutoRotate 方法的内容
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Override to allow orientations other than the default portrait orientation.
return YES;
}