Ipad UIModalViewController和UIImagePickerController旋转问题
情况就是这样: 我有一个viewController,它是这样显示的:Ipad UIModalViewController和UIImagePickerController旋转问题,ipad,rotation,uiimagepickercontroller,modalviewcontroller,uiinterfaceorientation,Ipad,Rotation,Uiimagepickercontroller,Modalviewcontroller,Uiinterfaceorientation,情况就是这样: 我有一个viewController,它是这样显示的: AddAttachmentPhotoVideoViewController * addAttachment = [[AddAttachmentPhotoVideoViewController alloc]initWithNibName:nil bundle:nil attachmentType:AtImage]; addAttachment.modalPresentationStyle = UIModalPresentati
AddAttachmentPhotoVideoViewController * addAttachment = [[AddAttachmentPhotoVideoViewController alloc]initWithNibName:nil bundle:nil attachmentType:AtImage];
addAttachment.modalPresentationStyle = UIModalPresentationFormSheet;
addAttachment.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:addAttachment animated:YES];
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];
在addAttachment
中,有一个按钮可以通过以下方式打开相机:
AddAttachmentPhotoVideoViewController * addAttachment = [[AddAttachmentPhotoVideoViewController alloc]initWithNibName:nil bundle:nil attachmentType:AtImage];
addAttachment.modalPresentationStyle = UIModalPresentationFormSheet;
addAttachment.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:addAttachment animated:YES];
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
的帧错误,并且旋转不正确
换句话说,当显示摄影机时,其下的模态视图控制器不接收旋转,因此,当我关闭选择器时,视图控制器的帧完全错误
谢谢…您必须告诉
AddAttachmentPhotoVideoViewController
它应该自动旋转到所有界面方向。默认情况下,YES
仅针对纵向方向返回。添加以下方法以允许对所有方向进行自动旋转:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
您必须告诉
AddAttachmentPhotoVideoViewController
它应该自动旋转到所有界面方向。默认情况下,YES
仅针对纵向方向返回。添加以下方法以允许对所有方向进行自动旋转:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
必须手动处理ViewController的旋转
前台ViewController应将旋转消息传播到其后面的所有ViewController。必须手动处理ViewController的旋转
前台ViewController应该将旋转消息传播到它后面的所有ViewController。Hi MaTTP,您能提供一些代码片段来说明解决方案吗?谢谢您好,MaTTP,您能提供一些代码片段来说明解决方案吗?谢谢