0

我有 2 个问题,关于Sencha touchphone gap;

我正在阅读 Ajith kumar 的 SenchaTouch CookBook。我正在按照第 1 章中给出的示例程序进行操作。所以据此我做了以下。

这是我的index.html

<!DOCTYPE HTML>
    <html>
        <head>
            <title>Yapps! - Your daily applications!</title>
            <link rel="stylesheet" href="sencha-
                touch/resources/css/sencha-touch.css" type="text/css">
                <link rel="stylesheet" href="sencha-
                    touch/resources/css/yapps-all.css" type="text/css">
                <script type="text/javascript" charset="utf-8"
                    src="phonegap.1.0.0.js"></script>
                <script type="text/javascript" charset="utf-8" src="sencha-
                    touch/sencha-touch.js"></script>
                <script type="text/javascript" charset="utf-8"
                    src="ch01/ch01_03.js"></script>
                <script type="text/javascript" charset="utf-8" src="sencha-
                    touch/yapps-all.js"></script>



        </head>
        <body></body>
    </html>

ch01_03.js文件。被告知将这些 .JS 文件添加到 WWW 文件夹中,但我无法在该文件夹中添加任何文件,因此我将其添加到文件夹之外。

Ext.setup({
          onReady: function() {
          var supportedFeatures = "Ext.supports.AudioTag : " +
          (Ext.supports.AudioTag ? "On" : "Off");
          supportedFeatures += "\nExt.supports.CSS3BorderRadius : " +
          (Ext.supports.CSS3BorderRadius ? "On" : "Off");
          supportedFeatures += "\nExt.supports.CSS3DTransform : " +
          (Ext.supports.CSS3DTransform ? "On" : "Off");
          supportedFeatures += "\nExt.supports.CSS3LinearGradient : " +
          (Ext.supports.CSS3LinearGradient ? "On" : "Off");
          supportedFeatures += "\nExt.supports.Canvas : " +
          (Ext.supports.Canvas ? "On" : "Off");
          supportedFeatures += "\nExt.supports.DeviceMotion : " +
          (Ext.supports.DeviceMotion ? "On" : "Off");
          supportedFeatures += "\nExt.supports.Float : " +
          (Ext.supports.Float ? "On" : "Off");
          supportedFeatures += "\nExt.supports.GeoLocation : " +
          (Ext.supports.GeoLocation ? "On" : "Off");
          supportedFeatures += "\nExt.supports.History : " +
          (Ext.supports.History ? "On" : "Off");
          supportedFeatures += "\nExt.supports.OrientationChange : " +
          (Ext.supports.OrientationChange ? "On" : "Off");
          supportedFeatures += "\nExt.supports.RightMargin : " +
          (Ext.supports.RightMargin ? "On" : "Off");
          supportedFeatures += "\nExt.supports.SVG : " +
          (Ext.supports.SVG ? "On" : "Off");
          supportedFeatures += "\nExt.supports.Touch : " +
          (Ext.supports.Touch ? "On" : "Off");
          supportedFeatures += "\nExt.supports.Transitions : " +
          (Ext.supports.Transitions ? "On" : "Off");
          supportedFeatures += "\nExt.supports.TransparentColor : " +
          (Ext.supports.TransparentColor ? "On" : "Off");
          supportedFeatures += "\nExt.supports.VML : " +
          (Ext.supports.VML ? "On" : "Off");
          Ext.Msg.alert("INFO", supportedFeatures);
          }
          });

1.) 问题是当我在 iPhone 和 Stimulator 上运行它时,我只看到一个空白屏幕。这是怎么回事,我应该怎么做才能让警报显示在视图上?

2.) 我需要检测我正在运行应用程序的设备。在书中,它展示了如何检测 iPad、Android 应用程序和 Blackberry。但不是 iPhone。如何检测 iPhone?

Ext.setup({
          onReady: function() {

          if (Ext.is.Android)
          Ext.Msg.alert("INFO", "Welcome Android user!");
          if (Ext.is.Blackberry)
          Ext.Msg.alert("INFO", "Welcome Blackberry user!");
          if (Ext.is.iPad)
          Ext.Msg.alert("INFO", "Welcome iPad user!");

          } });
4

1 回答 1

1

由于这个问题被标记在 下sencha-touch-2,我假设您使用的是 Sencha Touch 2。

Ext.isSencha Touch 2.0 版已弃用

相反,您可以使用Ext.env.OSpackage 来检测设备上正在运行的操作系统。

此外,您可以使用 is 属性来检测特定设备,如 iPad、iPhone、Android 等。

  • Ext.os.is.Android: 安卓平台
  • Ext.os.is.iPhone: 苹果手机
  • Ext.os.is.iPad: iPad等..

编辑 :

是的,您可以检测到 p'cular 设备。检查下面的代码...

var navigation = Ext.global.navigator,
    userAgent = navigation.userAgent,
    osEnv, osName, deviceType;

Ext.os = osEnv = new this(userAgent, navigation.platform);

osName = osEnv.name;

var search = window.location.search.match(/deviceType=(Tablet|Phone)/),
nativeDeviceType = window.deviceType;

if (search && search[1]) {
    deviceType = search[1];
}
else if (nativeDeviceType === 'iPhone') {
    deviceType = 'Phone';
}
else if (nativeDeviceType === 'iPad') {
    deviceType = 'Tablet';
}

使用 PhoneGap 的 Sencha Touch MVC 的好例子

于 2012-04-28T08:43:51.870 回答