您不必“将 UIImagePicker 控制器锁定为纵向模式”。正如您所说的“当它更改为横向模式时,它看起来有些奇怪”实际上我不知道您为什么说它看起来很奇怪。但是,这是我的 UIImagePicker 视图在横向模式下看起来很奇怪的体验。即:当 AViewController 作为根视图控制器时。并且 BViewController 的视图将子视图添加到 AViewController 的视图中。在BViewController presentModalViewController:UIImagePickerController
中。UIImagePicker 视图在横向模式下看起来很奇怪。
这个问题的解决方案是UIImagePickerController
在presentModelViewController之前设置为根视图控制器。下面的源代码显示了详细信息:
- (void) onCameraButtonTapped:(UIBarButtonItem *)buttonItem
{
//backupRootController it's use as a backup, it will recover after close the image picker controller.
self.backupRootController = [[UIApplication sharedApplication] keyWindow].rootViewController;
UIImagePickerController * imageController = [[UIImagePickerController alloc] init];
imageController.sourceType = UIImagePickerControllerSourceTypeCamera;
imageController.delegate = self;
....
[[[UIApplication sharedApplication] keyWindow] setRootViewController:imageController];
[self presentModalViewController:imageController animated:YES];
[imageController release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[[[UIApplication sharedApplication] keyWindow] setRootViewController:self.backupRootController];
....
}
我希望这个解决方案可以在未来帮助其他人。——戈曼