繁体   English   中英

iOS Cordova Lock SplashScreen方向

[英]IOS Cordova Lock SplashScreen Orientation

背景

我正在使用Cordova将JavaScript部署到iOS设备。 与此同时,我正在使用CDVSplashScreen插件以显示自己的启动屏幕。

我需要什么帮助

我希望能够锁定“启动/启动”屏幕,然后允许该应用程序重新定向,就像对所有其他视图一样。

我尝试过的

我已将以下内容添加到我的config.xml文件中:

<preference name="SplashScreen" value="screen" />
<preference name="orientation" value="portrait" />
<preference name="SplashScreenDelay" value="1000000" />

我将以下代码添加到CDVSplashScreen.mCDVViewController + SplashScreen.m文件中:

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

结果:

我添加到config.xml文件中的内容似乎已将启动屏幕锁定为纵向模式...但是,在SplashScreen出现后,视图将自由旋转到横向模式。

我不认为supportedInterfaceOrientations函数可以在任何地方做任何事情-它仅在mainViewController中起作用(但是整个应用程序都停留在Portrait模式下)。

我的请求

以前有人使用过这种独特的插件组合吗? 您是如何解决的?

我尚未检查,但是您可以尝试以下操作:

  1. 根据需要锁定Xcode中的方向。 (Xcode-> General->部署信息)

  2. 将事件处理程序放入您的javascript中:

 window.addEventListener("orientationchange", function() { // Do some DOM-/CSS-manipulation depending on the value in window.orientation }, false); 

  1. 或者,您可以使用CSS进行更改:

 @media screen and (orientation: portrait) { /* rotate your container */ } @media screen and (orientation: landscape) { /* rotate your container */ } 

但是我不确定该设备是否正在触发该事件。

谢谢你们的建议。 我最终在MainViewController的以下函数中设置了方向

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
      self.acceptedOrientation = UIInterfaceOrientationMaskPortrait;
    }
  return self;
}

这似乎将SplashScreen锁定为纵向模式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM