2

情况是这样的: 我一直认为在这种方式提出的viewController:UIModalViewController和旋转的UIImagePickerController问题

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

您必须手动处理ViewController的旋转。

前景的ViewController应该传播转动消息的背后都ViewControllers。

+0

嗨MaTTP,你能提供一些代码片段来说明解决方案吗?谢谢! – 2013-12-11 03:02:32

0

你必须告诉AddAttachmentPhotoVideoViewController,它应该自动旋转到所有的接口方向。默认情况下,YES仅以纵向方向返回。添加以下方法以允许自动旋转到所有方向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
}