情况如下: 我有一个以这种方式呈现的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
的框架错误并且旋转不正确。
换句话说,当显示相机时,其下的模态视图控制器不接收旋转,因此,当我解除拾取器时,视图控制器的框架完全错误。
...谢谢
答案 0 :(得分:0)
您必须告诉AddAttachmentPhotoVideoViewController
它应该自动旋转到所有界面方向。默认情况下,仅为纵向方向返回YES
。添加以下方法以允许自动旋转到所有方向:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
答案 1 :(得分:0)
您必须手动处理ViewController的旋转。
前台ViewController应该将旋转消息传播到它后面的所有ViewControllers。