Cordova - iOS - 不允许所有方向

时间:2016-08-16 20:32:19

标签: ios cordova phonegap-build cordova-cli

我最近从Phongegap Build切换到了当地的cordova。我不能为我的生活弄清楚如何在iOS中获得方向以允许所有。这让我疯了。

我已经在配置中尝试了所有记录的方法,例如:

<platform name="ios">
    <preference name="orientation" value="all" />
</platform>

但这不起作用。我还尝试通过plugin手动设置plist属性,但这似乎也没有。我在这里错过了什么?当我打开.ipa文件时,那里的plist只有以下的方向属性:

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>

根据我的理解,应该有四个这样:

<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

2 个答案:

答案 0 :(得分:1)

首选项名称不区分大小写,正确的条目必须是:

    namespace Inventory_Program
{
    public partial class MainGUIPanel : Form
    {

        Login login = new Login();

        public MainGUIPanel()
        {
            InitializeComponent();

            //runs the current time and data
            currentTime.Start();

        }

        //Method is adding a horizontal line to the top panel
        private void topControlPanel_Paint(object sender, PaintEventArgs e)
        {

            Graphics graphics = e.Graphics;
            Pen pen = new Pen(Color.Black, 1);
            graphics.DrawLine(pen, 1091, 93, 00, 93);
            graphics.Dispose();

            nameLabel.Text = login.getName();

        }

        //allows for the current time and date to be displayed in the top panel
        private void currentTime_Tick(object sender, EventArgs e)
        {
            DateTime dateTime = DateTime.Now;

        }

        private void inventoryButton_Click(object sender, EventArgs e)
        {

        }
    }
}

docs:http://cordova.apache.org/docs/en/dev/config_ref/index.html#preference

如果您需要iPad和iPhone的特定值,cordova-custom-config非常棒。

答案 1 :(得分:0)

您可以使用cordova-custom-config插件实现此目的 - 在将插件安装到本地项目之后,将以下内容添加到config.xml中:

<platform name="ios">

    <!-- Set orientation on iPhone -->
    <config-file platform="ios" target="*-Info.plist" parent="UISupportedInterfaceOrientations">
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationPortraitUpsideDown</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
    </config-file>

    <!-- Set orientation on iPad -->
    <config-file platform="ios" target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad">
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationPortraitUpsideDown</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
    </config-file>

如果在XCode中打开项目,您应该能够看到在plist中设置了相关的方向。