UIModalViewController 和 UIImagePickerController 旋转问题
情况是这样的: 我有一个以这种方式呈现的 viewController:
AddAttachmentPhotoVideoViewController * addAttachment = [[AddAttachmentPhotoVideoViewController alloc]initWithNibName:nil bundle:nil attachmentType:AtImage];
addAttachment.modalPresentationStyle = UIModalPresentationFormSheet;
addAttachment.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:addAttachment animated:YES];
在 addAttachment
中,有一个以这种方式打开相机的按钮:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
imagePicker.allowsEditing = NO;
imagePicker.showsCameraControls = YES;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
imagePicker.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:imagePicker animated:YES];
问题如下:当我旋转设备 (iPad) 时,>imagePicker
会自行旋转,但 addAttachment
不会旋转;因此,当我关闭选择器时,addAttachment
的框架错误,并且无法正确旋转。
换句话说,当显示相机时,其下方的模态视图控制器不会接收旋转,因此,当我关闭选择器时,视图控制器的框架完全错误。
谢谢...
This is the situation:
I've a viewController that was presented in this way:
AddAttachmentPhotoVideoViewController * addAttachment = [[AddAttachmentPhotoVideoViewController alloc]initWithNibName:nil bundle:nil attachmentType:AtImage];
addAttachment.modalPresentationStyle = UIModalPresentationFormSheet;
addAttachment.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:addAttachment animated:YES];
in addAttachment
there is a button that open the camera in this way:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
imagePicker.allowsEditing = NO;
imagePicker.showsCameraControls = YES;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
imagePicker.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:imagePicker animated:YES];
The issue is the following: when I rotate the device (iPad) the imagePicker
rotates itself but the addAttachment
doesn't rotate; so when I dismiss the picker the addAttachment
has a wrong frame and it's not rotate properly.
In other words, when the camera is shown, the modal view controller under it, doesn't receive the rotation and so, when I dismiss the picker, the frame of view controller is totally wrong.
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须手动处理 ViewController 的旋转。
前台 ViewController 应该将旋转消息传播到其后面的所有 ViewController。
You must handle the rotation of your ViewController manually.
The foreground ViewController should propagate the rotation message to all ViewControllers behind of it.
您必须告诉
AddAttachmentPhotoVideoViewController
它应该自动旋转到所有界面方向。默认情况下,仅针对纵向返回YES
。添加以下方法以允许自动旋转到所有方向:You have to tell the
AddAttachmentPhotoVideoViewController
that it should auto-rotate to all interface orientations. By default,YES
is only returned for portrait orientation. Add the following method to allow auto-rotation to all orientations: