钛:平台检测和更换界面风格相应 [英] Titanium: platform detection and changing interface style accordingly

查看:127
本文介绍了钛:平台检测和更换界面风格相应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如你可能知道不同的平台需要稍微不同的UX / UI。

As you may be aware different platform will require slightly different UX/UI.

例如,当你设计的iPhone,你可能有一个返回按钮,但是当你构建Android,你不想后退按钮。

Example, when you design for the iphone, you might have a back button, however when you build for android, you do not want a back button.

其他的事情是图标,你可能对工具栏为iPhone对Android,只有2个按钮工具栏上的多个按钮。

Other things is icons, you might have multiple buttons on the toolbar on the android and only 2 buttons on the toolbar for the iphone.

所以,问题是...当你建立js文件定义接口,你建两个不同的界面js文件的每个特定于平台或仅有1 js文件,将根据检测平台UI改变。

So the question is...when you build the js file to define the interface, do you build TWO different interface js file each specific to the platform or just 1 js file that would change UI according to platform detection.

我想这可能是更容易有两套UI的特定于平台,而不是在平台上检测转变作风,因为UX甚至可能会有所不同,因此,code制的UX和UI是相当复杂?你觉得呢?

I think it might be easier to have two set of UI specific to the platform, rather than change style on platform detection, because the UX might even be different, so the code for UX and UI would be rather complex? what do you think?

推荐答案

我认为,具有特定于平台的两套UI是更好的选择。
示例应用程序(它自带内置钛工作室)展示了如何决定的平台。下面是示例应用程序的code:

I think, having two sets of UI specific to the platform is better option. the example applications (which comes in-built with titanium studio) shows how to decide the platform. Below is the code from the example application:

var osname = Ti.Platform.osname,
    version = Ti.Platform.version,
    height = Ti.Platform.displayCaps.platformHeight,
    width = Ti.Platform.displayCaps.platformWidth;

//considering tablet to have one dimension over 900px - this is imperfect, so you should feel free to decide
//yourself what you consider a tablet form factor for android
var isTablet = osname === 'ipad' || (osname === 'android' && (width > 899 || height > 899));

var Window;
if (isTablet) {
        Window = require('ui/tablet/ApplicationWindow');
}
else {
    // Android uses platform-specific properties to create windows.
    // All other platforms follow a similar UI pattern.
    if (osname === 'android') {
        Window = require('ui/handheld/android/ApplicationWindow');
    }
    else {
        Window = require('ui/handheld/ApplicationWindow');
    }
}
new Window().open();

这篇关于钛:平台检测和更换界面风格相应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆