【发布时间】:2015-10-15 08:32:52
【问题描述】:
我正在努力修改设备方向。我找到了这个 cordova 插件 https://github.com/gbenvenuti/cordova-plugin-screen-orientation,它可以与 cordova 应用程序一起使用,但不幸的是无法使用 IBM MobileFirst Platform Foundation 7.0(+Angular,Ionic)。
我还尝试根据https://forums.developer.apple.com/thread/6165 对屏幕方向 Cordova 插件进行小改动,但它仍然无法正常工作
这是看起来像 YoikScreenOrientation.h 的界面
@interface ForcedViewController : UIViewController
@property (strong, nonatomic) NSString *calledWith;
@end
和 YoikScreenOrientation.m
@implementation ForcedViewController
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
- (NSUInteger)supportedInterfaceOrientations {
NSLog(@"lockViewController to ALL Portrait < 9");
return UIInterfaceOrientationMaskPortrait;
}
#else
-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
NSLog(@"lockViewController to ALL Portrait > 9");
return UIInterfaceOrientationPortrait;
}
#endif
@end
我可以在日志中看到它通过supportedInterfaceOrientations 方法,但它没有将屏幕方向锁定为纵向。为了锁定或解锁设备方向,我是否遗漏了任何配置?
【问题讨论】:
-
1) 最终目标是什么?您是否尝试以编程方式完成锁定和解锁,而不是“常规”选项中的“设备方向”选项? 2) Angular 和 Ionic 与这个问题有什么关系? 3) 您是在物理设备中还是在 iOS 模拟器中进行测试?
-
1)目标是将屏幕方向锁定在一页然后再次解锁,我添加了常规选项解锁的图像以指出设备方向已解锁。 2) 没什么,只是我用来构建应用程序的框架,3) 是的,我在模拟器和真实设备上都进行了测试,并且行为相同。
标签: ios objective-c ibm-mobilefirst device-orientation