使用Appcelerator检测iPhone X.

时间:2018-03-02 13:16:35

标签: titanium-mobile appcelerator-titanium

我正在为我的项目使用自定义导航栏,我正在使用ios 7上边距的代码,如下所示;

var _IsIos7Plus = false;

if (Titanium.Platform.name == 'iPhone OS') {
    var _Version = Titanium.Platform.version.split(".");
    var _Major = parseInt(_Version[0], 10);

    if (_Major >= 7) {
        _IsIos7Plus = true;
    }
}

Alloy.Globals.Ios7TopMargin = _IsIos7Plus  == true ? 20 : 0;

但iPhone X模拟器显示20个空白。有没有办法检测iPhone X?

iPhone X iOS 11.2 Screenshot

iPhone 8 iOS 11.2 Screenshot

1 个答案:

答案 0 :(得分:5)

如果您先升级项目,请检查

  

Default-Portrait-2436h@3x.png

     

Default-Landscape-2436h@3x.png

启动屏幕

您可以检测到如下iPhoneX代码;

function myfunction() {
    var range2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Store").getRange("A1:A400").getValues();
    var folder = DriveApp.getFolderById('1guRQ0oePKFq9DgggbMwLKCk3yqEGphMe');
    Logger.log(range2);
    for (i = 1; i < range2.length; i++) {
        SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Store").getRange("B2").setValue(range2[i][0]);
        SpreadsheetApp.flush();
        var pdf = SpreadsheetApp.getActiveSpreadsheet().getAs('application/pdf');
        var name2 = range2[i - 1][0];
        var pdf2 = folder.createFile(pdf);
        pdf2.setName(name2);
    }
}