iOS 8.1系统下,UIImagePickerController存在一个bug,就是前几天写的博客中提到的水平放置pad,imagePicker打开相机后,镜头旋转了90°的问题,详情:http://blog.youkuaiyun.com/u010731949/article/details/50948017。
我在iOS8.1下,测试了QQ等软件,都存在这个UIImagePickerController的bug,估计Apple已经不在意这个了,,毕竟9.3啦
上次虽然是针对这个bug,做了小的调整,不过后来还是有个问题,就是:现在imagePicker打开相机时,镜头是正常的,但是旋转pad,镜头又再次旋转90°。
下面是做的另一个小调整,注意我的项目是横屏的,思路是,监听设备旋转通知,当设备旋转监听到pad旋转到UIDeviceOrientationPortraitUpsideDown、或者UIDeviceOrientationPortrait时,恢复imagePicker到原来的镜头方向_imagePicker.cameraViewTransform = CGAffineTransformMakeRotation(0); 当然如果默认应用是竖屏的,那么相应的对旋转到UIDeviceOrientationLandScape方向进行处理
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
- (void)orientChange:(NSNotification *)noti {
NSDictionary *notiDict = [noti userInfo];
UIDeviceOrientation orient = [UIDevice currentDevice].orientation;
switch (orient) {
case UIDeviceOrientationPortraitUpsideDown:
case UIDeviceOrientationPortrait:
_imagePicker.cameraViewTransform =
CGAffineTransformMakeRotation(0);
break;
default:
break;
}