我正在使用 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/