在iOS 6.0下展示UIImagePickerController时崩溃 [英] Crash on presenting UIImagePickerController under iOS 6.0

查看:117
本文介绍了在iOS 6.0下展示UIImagePickerController时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用仅通过 supportedInterfaceOrientation 属性支持横向方向。

My app only supports landscape orientations via the supportedInterfaceOrientation properties.

使用iOS 6之前的iOS,我的应用程序可以通过<$ c $成功加载 UIImagePickerController 的实例c> presentViewController:animated:completion:即使 UIImagePickerController 本身仅支持纵向方向。

Using an iOS prior to iOS 6, my app can successfully load an instance of UIImagePickerController via presentViewController:animated:completion: even though the UIImagePickerController itself only supports portrait orientation.

图像选择器只是向用户侧面展示自己。用户旋转手机,拾取他们的图像,然后旋转回横向。

The image picker simply presented itself sideways to the user. The user rotated the phone, picked their image, and then rotated back to landscape.

在iOS 6.0下,使用 UIImagePickerController调用 presentViewController:animated:completion: code>实例崩溃了应用程序。我可以通过向我的 supportedInterfaceOrientation 属性添加纵向选项来防止崩溃。

Under iOS 6.0, calling presentViewController:animated:completion: with the UIImagePickerController instance crashes the app. I can prevent the crash by adding portrait options to my supportedInterfaceOrientation properties.

但是,纵向操作对我的应用来说真的没有意义。我以为我可以使用 shouldAutorotateToInterfaceOrientation 来允许应用程序支持肖像,但只允许在这一个视图中旋转到肖像。但是现在该方法已被弃用,我不能在shouldAutorotate中使用相同的技术。

However, operating in portrait really does not make sense for my app. I had thought I could use shouldAutorotateToInterfaceOrientation to allow the app to "support portrait" but only be allowed to rotate to portrait in this one view. But now that method is deprecated, and I can't use the same technique with shouldAutorotate.

有没有人有任何想法如何在iOS 6.0下解决这个问题?

Does anyone have any ideas how I can get around this issue under iOS 6.0?

推荐答案

iOS 6.1 - 修复



从iOS 6.1开始,不再发生,遵循我的提示非常重要为了避免iOS 6.0.x下的崩溃,以下内容仍适用于此。

iOS 6.1 - fixed

As of iOS 6.1, this no longer occurs, it is very important to follow my tips in order to avoid a crash under iOS 6.0.x, the below still applies to that.

实际上这是iOS 6.0中的一个错误,这应该在未来的iOS版本中修复。

This is in actual fact a bug in iOS 6.0, this should be fixed in future iOS releases.

Apple的一位工程师解释了这个错误并在此处解决了一个问题: https://devforums.apple.com/message/ 731764

An engineer from Apple has explained this bug and a workaround here: https://devforums.apple.com/message/731764

这种情况正在发生,因为应用程序只想要横向,但是一些Cocoa Touch视图控制器需要严格的纵向方向,这是错误 - 而不是它们应该是需要更多然后肖像,但他们对Applicati的解释ons要求。

This is happening because the Application wants landscape orientation only but some Cocoa Touch View Controllers require strictly Portrait orientation which is the error - not that they should be requiring more then Portrait but their interpretation of the Applications requirements.

这方面的一个例子如下:

An example of this can be the following:


iPad app support landscape仅通过UIPopoverController显示UIImagePickerController
。 UIImagePickerController需要
纵向方向,但应用程序仅强制横向。错误
和...崩溃

iPad app supporting landscape only displays a UIImagePickerController via a UIPopoverController. The UIImagePickerController requires Portrait orientation, but the app is forcing landscape only. Error and... crash

其他报告为有问题的框架包括Game Center登录视图控制器。

Other frameworks that have been reported as problematic include the Game Center login view controller.

解决方法非常简单但不理想......您保持在info.plist /项目信息窗格中声明的正确方向,但在Application Delegate类中声明您允许所有方向。

The workaround is pretty simple but not ideal... You keep the correct orientations declared in your info.plist/project info pane, but in the Application Delegate class you declare that you allow all orientations.

现在,您添加到窗口的每个视图控制器必须指定它只能是横向。请查看链接以获取更多详细信息。

Now each View Controller you add to the window must specify itself that it can only be Landscape. Please check the link for more details.

我不能强调你不应该为子类化多少 UIImagePickerController 因为已接受的解决方案坚持要做。

I cannot stress how much you should not be subclassing UIImagePickerController as the accepted solution is insisting you do.

这里重要的是此类旨在按原样使用,不支持子类化

在我的情况下,我将此添加到我的应用程序的委托(我有一个仅景观应用程序),这告诉它可以显示的图像选择器,因为支持肖像:

In my case I added this to my application's delegate (I have a landscape only app), this tells the image picker it can display, because portrait is supported:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    return UIInterfaceOrientationMaskAll;
}

然后在我的视图控制器中碰巧是 UINavigationController ,我包含了以下类别:

And then in my view controller which happened to be a UINavigationController, I included a category with the following:

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

现在我的应用程序没有旋转,图像选择器询问代表是否它可以显示为肖像,它被告知没关系。所以一切都很好。

Now my app doesn't rotate, and the image picker asks the delegate if it can display as portrait and it gets told that's okay. So all plays out well.

这篇关于在iOS 6.0下展示UIImagePickerController时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆