因为我正在使用 iOS 应用程序仅支持 Portrait Orientation
.
但我遇到了一些与方向相关的问题。
-(void)imagePickerController:(UIImagePickerController *)picker
[self.delegate openCamera]
;//从 C1.view 调用-(void)openCamera //declared in P1.view
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;>
[self presentModalViewController:picker animated:YES];
}
presentModalViewController 我的 View 出现在 Landscapmode 而不是 Portrait
模式。
- (BOOL)shouldAutorotate {
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
此方法在 View Controller (P1 和 C1)中定义,并且在模型 View 关闭时也被调用,但是我的 View Controller 仍然在景观中,这不应该发生。
此代码在 iOS6 中运行良好,但在 iOS7 中运行良好
最佳答案
我认为 preferredInterfaceOrientationForPresentation
不应该返回位掩码。你可以试试:- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
关于ios - 关闭 ViewController 后,我的 View 保持在 iOS 7 中以前的 View Controller 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24424852/