iPad 2 UIImagePickerController 相机自动旋转让我抓狂!

发布于 2024-11-07 15:35:10 字数 345 浏览 3 评论 0原文

我已经尝试解决这个问题有一段时间了,但一无所获。

我正在 iPad 2 上使用相机 - 我的应用程序处于横向模式,但我想在纵向模式下使用相机。我似乎无法强制 ImagePicker a(进入纵向模式)和 b(停止自动旋转)。

有什么方法可以强制 ImagePicker 进入纵向(或横向),和/或停止它自动旋转?

即使应用程序处于横向状态并且设置为仅在横向方向返回“YES”,但 ImagePicker 会忽略这一点,并在您旋转 iPad 2 时旋转为纵向。

如果我可以强制它保持横向状态(尽管并不理想),我可以重新设计应用程序以在风景中使用相机,但我似乎甚至无法做到这一点!

非常感谢任何帮助!

I've been trying to sort this one out for a while and getting nowhere.

I'm using the camera on the iPad 2 - my application is in landscape, but I want to use the camera in portrait mode. I just can't seem to force the ImagePicker a, into Portrait mode, and b, to stop auto-rotating.

Is there any way that you can force the ImagePicker into portrait (or landscape), and/or to stop it auto-rotating?

Even though the App is in landscape and is set to return YES only to landscape orientations, the ImagePicker ignores that and rotates into portrait when you rotate the iPad 2.

If I could force it into staying in landscape then (although not ideal) I could re-design the app to use the camera in landscape, but I don't seem to be able to do even that!

Any help greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

铁憨憨 2024-11-14 15:35:10

您需要重写的方法称为:

_isSupportedInterfaceOrientation:

所以它应该看起来像这样:

@interface PortraitImagePickerController : UIImagePickerController {

}

@end





@implementation PortraitImagePickerController
- (BOOL)_isSupportedInterfaceOrientation:(UIDeviceOrientation)orientation{
    return UIDeviceOrientationIsPortrait(orientation);
}
@end

但它绝对是私有方法,因此Apple可能会拒绝您的应用程序

The method that you need to override called:

_isSupportedInterfaceOrientation:

So it should look something like this :

@interface PortraitImagePickerController : UIImagePickerController {

}

@end





@implementation PortraitImagePickerController
- (BOOL)_isSupportedInterfaceOrientation:(UIDeviceOrientation)orientation{
    return UIDeviceOrientationIsPortrait(orientation);
}
@end

But it's definitely private method so Apple may reject your app

仅一夜美梦 2024-11-14 15:35:10

好吧,我找到了一种更方便的方法,并且没有使用私有代码的风险。

子类 UIImagePickerController 并在其 .m 文件中添加以下方法。

- (NSUInteger)supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskPortrait;
}

Well i have found a more convenient way and has no risk of using private code.

Sub class a UIImagePickerController and add following method in its .m file.

- (NSUInteger)supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskPortrait;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文