我有父視圖控制器和另一個模式視圖控制器。 我父母的背景下提出的模態視圖控制器:IOS視圖控制器方向
readingViewController * reading_view_controller = [[readingViewController alloc] initWithNibName:@"readingViewController" bundle:nil];
[self setModalPresentationStyle:UIModalPresentationCurrentContext];
[self presentModalViewController:reading_view_controller animated:YES];
家長的viewController不會東方園林;所以,我加入在父的viewController這些方法:
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortraitUpsideDown|UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
所呈現的viewController(模態呈現)應定向到所有可能的方向;所以,我添加了這些方法:
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
但是,因爲我認爲(UIModalPresentationCurrentContext),所提出的viewController不IOS 6.0,而它正在爲IOS 5.0預計
如何解決這個定位問題請問?
改變方向,我實現它,但沒有改變 – yasserislam
是在其他控制器的的viewController?我的意思是像navigationController或tabViewController。如果它在它們下面,那麼你應該繼承它們以覆蓋方向方法或創建類別來覆蓋它們。這應該使它工作。 –