簡體   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