UIImagePickerController overlay自动旋转 [英] UIImagePickerController overlay autorotate

查看:209
本文介绍了UIImagePickerController overlay自动旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用UIImagePicker在我的iPhone应用程序上访问摄像头。我想要能够有两个不同的叠加为imagepicker,取决于iPhone的方向。有可能做到这一点吗?似乎如果我把下面的方法放在拥有UIImagePickerController的类中,它根本不会被调用,并且在任何uiviewcontroller上面,只有当UIImagePickerController没有被激活时才被调用。

I am using the UIImagePicker to access the camera on my iPhone app. I would like to be able to have two different overlays for the imagepicker, depending on the orientation of the iPhone. Is it possible to do this? It seems like if I place the following method in the class that owns the UIImagePickerController, it does not get called at all, and in any uiviewcontroller above that it only gets called once the UIImagePickerController is not active.

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
   NSLog(@"shouldAutorotate called");
   return YES;
}

任何想法如何达到预期效果?

Any idea how to achieve the desired effect?

推荐答案

文档说UIImagePickerController只支持纵向模式,因此可能没有支持的方式。

The documentation says that the UIImagePickerController only supports portrait mode so it could be that there's no supported way of doing this.

如果你使用presentModalViewController:animated来显示imagepicker,那么我相信只有模态控制器会得到像shouldAutorotateToInterfaceOrientation的消息。

If you're using presentModalViewController:animated to display the imagepicker then I believe only the modal controller will get messages like shouldAutorotateToInterfaceOrientation.

通常你可能能够子类化UIImagePickerController来重写相应的方法,但似乎也不支持子类化。

Normally you might be able to subclass UIImagePickerController to override the appropriate methods, but it seems that subclassing isn't supported either.

我怀疑你必须实际使用UIAccelerometer和

I suspect that you're going to have to actually use UIAccelerometer and do manual view rotation on your overlay view in response to acceleration messages.

编辑:

实际上,请尝试使用[NSNotificationCenter addObserver:for UIDeviceOrientationDidChangeNotification。

Actually, try using [NSNotificationCenter addObserver: for UIDeviceOrientationDidChangeNotification.

这篇关于UIImagePickerController overlay自动旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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