How to fix orientation on Windows Phone 8 Phonegap app?

我们两清 提交于 2019-12-07 17:09:02

问题


Does anybody know how to fix the orientation in Phonegap app for Windows Phone 8?

I want the app only supports portrait orientation.


回答1:


The accepted answer isn't right

the right answer is:

Open the

MainPage.xaml

and change this for the orientation you want, minie was Portrait

SupportedOrientations="Portrait" Orientation="Portrait"




回答2:


You need to create a plugin if you want to do this dynamically. First create a handler in your MainPage.xaml file:

   public MainPage()
    {
        ...
        ScreenLockCommand.OnScreenLock += HandleScreenLock;
        ...
    }       

    public void HandleScreenLock(SupportedPageOrientation orientation)
    {
        this.Dispatcher.BeginInvoke((Action)(() =>
        {
            this.SupportedOrientations = orientation;
        }));
    }

Then call it from your plugin like-so:

OnScreenLock(SupportedPageOrientation.Portrait);

or

OnScreenLock(SupportedPageOrientation.PortraitOrLandscape);




回答3:


Add this line to your config.xml file

<preference name="orientation" value="portrait" />


来源:https://stackoverflow.com/questions/16037863/how-to-fix-orientation-on-windows-phone-8-phonegap-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!