问题
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