检测 UIImagePickerController 中的方向变化?
我试图检测 UIImagePickerController 中的方向变化(它继承自 UINavigationController : UIViewController : UIResponder : NSObject),并且我尝试覆盖 UIViewController 中的方法 - (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation
但没有成功。 ?
有什么建议吗
提前致谢...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不支持子类化 UIImagePickerController!
也许您可以注册 UIDevice 的“nofollow noreferrer”>
UIDeviceOrientationDidChangeNotification
并使用它?Subclassing UIImagePickerController is not supported!
Maybe you could register for
UIDeviceOrientationDidChangeNotification
fromUIDevice
and use this?现在在这里回答已经太晚了,但我正在扩展@Adam Woś的答案,
在呈现
UIImagePickerController
之前,当
UIImagePickerController
被解雇时不要忘记,另请注意,根据 @FelixLam 对 @Adam Woś 答案的评论,
为了处理这种情况,需要实现 CoreMotion(替代的 UIAccelerometer iOS <6.0)来检测设备方向是否被锁定。这是
UIAccelerometer
http://blog.sallarp. 的博客。 com/iphone-accelerometer-device-orientation/ 这是用于CoreMotion
https ://github.com/tastyone/MotionOrientation 您必须使用一些逻辑来检查这一点。祝你好运!
This is too late to answer here, but I'm expanding @Adam Woś answer,
Before presenting
UIImagePickerController
,When
UIImagePickerController
get dismiss don't forget,Also note that, as per @FelixLam comment on @Adam Woś answer,
To handle this situation, one need to implement
CoreMotion
(alternativeUIAccelerometer
iOS < 6.0) to detect that device orientation is locked or not. Here's the blog forUIAccelerometer
http://blog.sallarp.com/iphone-accelerometer-device-orientation/ and this is forCoreMotion
https://github.com/tastyone/MotionOrientation You'll have to kick some logic to check this.Good luck!
来自官方 UIImagePickerController 文档:
From the official UIImagePickerController documentation: