相关疑难解决方法(0)

如何在iOS 6中以编程方式更改设备方向

iOS 5中,我们可以通过编程方式更改设备方向,如下所示:

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
Run Code Online (Sandbox Code Playgroud)

但是在iOS 6 setOrientation中已弃用,我如何在iOS 6中以编程方式更改设备方向?

objective-c uiinterfaceorientation ios

45
推荐指数
5
解决办法
7万
查看次数

iPad iOS7 - UIPopoverController中的UIImagePickerController具有错误的预览图像

我在UIPopoverController中使用UIImagePickerController,它与iOS6完美配合.使用iOS 7时,显示捕获图像的"预览"图像会旋转,但如果我拍照,则会正确保存.

这就是我选择的方式:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
                              (NSString *) kUTTypeImage,
                              nil];
imagePicker.allowsEditing = NO;
Run Code Online (Sandbox Code Playgroud)

并将其添加到弹出控制器:

self.imagePickerPopOver = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
    [self.imagePickerPopOver presentPopoverFromRect:CGRectMake(aPosViewA.x, cameraButton_y, 100.0, 30.0) inView:self.detailViewController.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Run Code Online (Sandbox Code Playgroud)

这些是UIScrollView上按钮位置的计算,以显示正确位置的弹出窗口:

presentPopoverFromRect:CGRectMake(aPosViewA.x, cameraButton_y, 100.0, 30.0)
Run Code Online (Sandbox Code Playgroud)

我不认为问题就在那里,因为我尝试了几种组合.

我还尝试在全屏模式下捕获图像,但应用程序只允许使用横向模式.如果以纵向模式拍摄图像并且取消模态视图,则应用程序也将保持纵向模式.如果模态视图被解除,我找不到阻止UIImagePickerController切换到纵向模式或强制应用程序回到横向模式的方法.

UPDATE

我从这里得到了答案,又向前迈进了一步.

我在创建选择器之后和显示弹出窗口之前转换视图:

switch ([UIApplication sharedApplication].statusBarOrientation) {
        case UIInterfaceOrientationLandscapeLeft:
            self.imagePicker.view.transform = CGAffineTransformMakeRotation(M_PI/2);
            break;
        case UIInterfaceOrientationLandscapeRight:
            self.imagePicker.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
            break;
        default:
            break;
    }
Run Code Online (Sandbox Code Playgroud)

只要我不转动iPad,它就能正常工作.为此,我正在注册方向更改事件:

[[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(orientationChanged:)  name:UIDeviceOrientationDidChangeNotification  object:nil];
Run Code Online (Sandbox Code Playgroud)

并更改选择器视图:

- …
Run Code Online (Sandbox Code Playgroud)

uiimagepickercontroller uipopovercontroller uiinterfaceorientation ios ios7

26
推荐指数
1
解决办法
9834
查看次数

相机图像旋转问题

我在这里遇到一个非常奇怪的问题.当我在纵向模式下单击图像并上传它然后再次获取它时,显示旋转90度逆时针方向.但是当我在相机胶卷中看到它时,它会以正确的方向显示.我已经尝试了几乎所有可能的链接/代码来解决这个问题,但似乎没有任何帮助.我以JPEG格式保存图像.请帮助这个人.提前致谢!!

exif objective-c uiimagepickercontroller uiimage ios

7
推荐指数
1
解决办法
3430
查看次数

如何在仅在iOS-6中支持横向定位的应用中使用UIImagePickerController?

我正在开发一个仅支持横向定位的应用程序.它使用a UIImagePickerController从库中选择图像和/或视频.应用程序在iOS-5或之前运行良好但在我尝试呈现图像选择器控制器时它会崩溃.它在崩溃后给出以下消息:

*由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'

landscape uiimagepickercontroller uiinterfaceorientation ios6

3
推荐指数
1
解决办法
4368
查看次数