objective-c - UIImagePickerController 叠加自动旋转

标签 objective-c iphone cocoa-touch camera

我正在使用 UIImagePicker 访问我的 iPhone 应用程序上的相机。我希望能够根据 iPhone 的方向为图像选择器提供两个不同的叠加层。是否有可能做到这一点?似乎如果我将以下方法放在拥有 UIImagePickerController 的类中,它根本不会被调用,并且在上面的任何 uiviewcontroller 中它只会在 UIImagePickerController 不活动时被调用。

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

知道如何达到预期的效果吗?

最佳答案

文档说 UIImagePickerController 只支持纵向模式,所以可能没有支持的方法。

如果您使用 presentModalViewController:animated 来显示图像选择器,那么我相信只有模态 Controller 会收到像 shouldAutorotateToInterfaceOrientation 这样的消息。

通常您可以子类化 UIImagePickerController 以覆盖适当的方法,但似乎也不支持子类化。

我怀疑您将不得不实际使用 UIAccelerometer 并在叠加 View 上执行手动 View 旋转以响应加速消息。

编辑:

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

关于objective-c - UIImagePickerController 叠加自动旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1974858/

相关文章:

objective-c - 核心数据 - 获取具有可选属性的对象

objective-c - 嵌套的 NSUserDefaults 数组读/写

ios - 使用 Storyboard在同一容器 View 中的多个 View

iOS 7 色调颜色去饱和度通知

ios - 应用程序 :openURL:sourceApplication:annotation return NO versus YES

objective-c - 在 Objective-C 中匹配 CJK 扩展 B

objective-c - Facebook iOS SDK : Retrieve User's Phone Number and Country

ios - 我到底应该什么时候调用 [super viewWillAppear :] and when not?

ios - 使用未解析的标识符 'objectAtIndexPath'

iphone - 如何在导航栏中添加图像