apa*_*dam 23 objective-c uiimagepickercontroller ipad ios ios7
我的图像选择器视图控制器设置在弹出控制器内.在iOS 6上,一切都运行良好,但在iOS 7上,图像旋转,所有移动都在做:当转动iPad时,左图像向下移动,向上移动图像向左移动等.
这是显示我的相机的代码:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
objPopView = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[objPopView presentPopoverFromRect:CGRectMake(842, 163, 0, 0)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionRight
animated:YES];
Run Code Online (Sandbox Code Playgroud)
我的应用仅使用横向模式,现在图像被旋转:
Kju*_*uly 17
正如Apple的官方文件所说:
显示用户界面.在iPhone或iPod touch上,通过调用当前活动视图控制器的presentViewController:animated:completion:方法,以模态方式(全屏)执行此操作,将配置的图像选择控制器作为新视图控制器传递.
在iPad上,呈现图像选择器的正确方法取决于其源类型,如下表所示:
- 相机照片:全屏使用
- 库已保存:必须使用弹出窗口
- 相册:必须使用弹出窗口
...
在iPad上,如果指定源类型为UIImagePickerControllerSourceTypeCamera,则可以模态(全屏)或使用弹出窗口显示图像选择器.但是,Apple建议您仅全屏显示相机界面.
虽然它说"你可以模态地(全屏)或使用弹出窗口呈现图像选择器",正如你所看到的那样使用弹出窗口会导致这个奇怪的问题.我想这可能是iOS 7 SDK上的一个错误.
我仍然试图解决这个问题,但是现在,我能说的唯一方法是以模态方式显示它
-presentViewController:animated:completion:
Run Code Online (Sandbox Code Playgroud)
方法,全屏显示(实际上,我不喜欢这种方式).
在Apple的开发论坛上讨论了一个关于它的THREAD,你可以看看它.;)
请尝试以下方法:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
CGFloat scaleFactor=1.3f;
switch ([UIApplication sharedApplication].statusBarOrientation) {
case UIInterfaceOrientationLandscapeLeft:
imagePicker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * 90 / 180.0), scaleFactor, scaleFactor);
break;
case UIInterfaceOrientationLandscapeRight:
imagePicker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * -90 / 180.0), scaleFactor, scaleFactor);
break;
case UIInterfaceOrientationPortraitUpsideDown:
imagePicker.cameraViewTransform = CGAffineTransformMakeRotation(M_PI * 180 / 180.0);
break;
default:
break;
}
objPopView = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[objPopView presentPopoverFromRect:CGRectMake(842, 163, 0, 0)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionRight
animated:YES];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6225 次 |
最近记录: |