2013-10-30 73 views
0

我有一個奇怪的行爲。 我在xcode上運行我的sencha touch 2/phonegap 2.0應用程序4.3xcode不能識別sencha touch javascript語法

我的一些視圖,其中只加載模擬器/設備。而它在瀏覽器上加載的很好。

我沒有在日誌中得到任何特殊錯誤,所以我開始在視圖中刪除項目。 終於,我發現XCODE有問題來識別一些xtype,如「fieldset」,「emailfield」,「passwordfield」等。 在將fieldset改爲「container」並將字段添加到「textfield」我的視圖被加載成功地。奇怪啊?

這一點在下面的代碼:

/* 
* File: app/view/loginformpanel.js 
* 
* This file was generated by Sencha Architect version 2.2.2. 
* http://www.sencha.com/products/architect/ 
* 
* This file requires use of the Sencha Touch 2.1.x library, under independent license. 
* License of Sencha Architect does not include license for Sencha Touch 2.1.x. For more 
* details see http://www.sencha.com/license or contact [email protected] 
* 
* This file will be auto-generated each and everytime you save your project. 
* 
* Do NOT hand edit this file. 
*/ 

Ext.define('MyApp.view.loginformpanel', { 
    extend: 'Ext.form.Panel', 

    config: { 
     baseCls: 'fbloginpanel', 
     id: 'loginformpanel', 
     itemId: 'loginformpanel', 
     layout: { 
      type: 'vbox' 
     }, 
     scrollable: { 
      direction: 'vertical' 
     }, 
     items: [ 
      { 
       xtype: 'container', 
       flex: 20, 
       cls: 'fblogin', 
       layout: { 
        type: 'vbox' 
       }, 
       items: [ 
        { 
         xtype: 'container', 
         flex: 3, 
         cls: 'wholepageRelative' 
        }, 
        { 
         xtype: 'container', 
         flex: 18, 
         cls: 'wholepageRelative', 
         layout: { 
          type: 'vbox' 
         }, 
         items: [ 
          { 
           xtype: 'container', 
           flex: 8, 
           docked: 'top', 
           layout: { 
            type: 'vbox' 
           }, 
           items: [ 
            { 
             xtype: 'fieldset', 
             flex: 2, 
             cls: 'loginmargin', 
             docked: 'top', 
             title: 'Existing User', 
             items: [ 
              { 
               xtype: 'emailfield', 
               id: 'email1', 
               itemId: 'email1', 
               name: 'email1', 
               placeHolder: 'Email' 
              }, 
              { 
               xtype: 'passwordfield', 
               id: 'password1', 
               itemId: 'password1', 
               name: 'password1', 
               placeHolder: 'Password' 
              } 
             ] 
            }, 
            { 
             xtype: 'button', 
             flex: 1, 
             cls: [ 
              'loginmargin', 
              'Signbutton' 
             ], 
             docked: 'bottom', 
             id: 'reglogin', 
             itemId: 'reglogin', 
             ui: 'round', 
             icon: '', 
             scope: this 
            } 
           ] 
          }, 
          { 
           xtype: 'container', 
           flex: 10, 
           layout: { 
            type: 'vbox' 
           }, 
           items: [ 
            { 
             xtype: 'container', 
             flex: 10, 
             layout: { 
              type: 'vbox' 
             }, 
             items: [ 
              { 
               xtype: 'fieldset', 
               flex: 4, 
               cls: 'loginmargin', 
               docked: 'top', 
               layout: { 
                type: 'vbox' 
               }, 
               title: 'New User', 
               items: [ 
                { 
                 xtype: 'textfield', 
                 id: 'username', 
                 itemId: 'username', 
                 name: 'username', 
                 placeHolder: 'Username' 
                }, 
                { 
                 xtype: 'passwordfield', 
                 id: 'password', 
                 itemId: 'password', 
                 name: 'password', 
                 placeHolder: 'Password' 
                }, 
                { 
                 xtype: 'emailfield', 
                 id: 'email', 
                 itemId: 'email', 
                 name: 'email', 
                 placeHolder: 'Email' 
                }, 
                { 
                 xtype: 'passwordfield', 
                 hidden: true, 
                 id: 'hashpassword', 
                 itemId: 'hashpassword', 
                 label: 'ססמא', 
                 name: 'hashpassword' 
                }, 
                { 
                 xtype: 'numberfield', 
                 hidden: true, 
                 label: 'Field', 
                 name: 'bfacebook' 
                }, 
                { 
                 xtype: 'numberfield', 
                 hidden: true, 
                 label: 'Field', 
                 name: 'bregister' 
                } 
               ] 
              }, 
              { 
               xtype: 'container', 
               flex: 4, 
               minHeight: 100, 
               layout: { 
                type: 'vbox' 
               }, 
               items: [ 
                { 
                 xtype: 'button', 
                 cls: [ 
                  'loginmargin', 
                  'Regbutton' 
                 ], 
                 docked: 'top', 
                 id: 'regbtn', 
                 itemId: 'regbtn', 
                 ui: 'round', 
                 icon: '', 
                 scope: this 
                }, 
                { 
                 xtype: 'button', 
                 cls: 'fbLoginbtn', 
                 docked: 'bottom', 
                 height: '', 
                 id: 'fbloginbtn1', 
                 itemId: 'fbloginbtn1', 
                 ui: '' 
                } 
               ] 
              }, 
              { 
               xtype: 'container', 
               flex: 2, 
               docked: 'bottom', 
               height: 50 
              } 
             ] 
            } 
           ] 
          } 
         ] 
        } 
       ] 
      }, 
      { 
       xtype: 'toolbar', 
       cls: 'registerToolbar', 
       docked: 'top', 
       items: [ 
        { 
         xtype: 'button', 
         baseCls: 'backbtn', 
         docked: 'left', 
         height: '', 
         id: 'loginbackbtn', 
         itemId: 'loginbackbtn', 
         width: '18%' 
        } 
       ] 
      } 
     ], 
     listeners: [ 
      { 
       fn: 'onLoginbackbtnTap', 
       event: 'tap', 
       delegate: '#loginbackbtn' 
      } 
     ] 
    }, 

    onLoginbackbtnTap: function(button, e, eOpts) { 
     //var Screen = Ext.ComponentQuery.query('#fbloginpanel'); 

     Ext.Viewport.setActiveItem(Ext.ComponentQuery.query('#fbloginpanel')[0]); 
     //Ext.Viewport.show(); 
    } 

}); 

現在我有其他的意見更多的問題,即使沒有這些情況。

確實有人有類似的問題嗎? 請幫助我。

回答

0

只是一個很快的猜測,但是您沒有在您發佈的課程中使用「requires」關鍵字。

您的視圖完全有可能無法在模擬器或設備上加載,因爲應用程序在構建後不知道如何解析這些xtypes,因爲「開發」和「生產」模式非常不同。

作爲一種最佳實踐,請始終對您的課程使用的每個依賴項使用「requires」。

+0

謝謝。我正在使用建築師。所以這是它生成的代碼。在我的主App.js中,我看到了需求和路徑,並要求EXT。庫(是不是足夠):Ext.Loader.setConfig({ disableCaching:假, 路徑:{ 分機: '觸摸/ SRC', 'Ext.device': '設備', 「MyApp.Facebook ':'app /' } }); Ext.application({ 要求:[ 'Ext.device.Geolocation', 'Ext.device.Notification', 'Ext.TitleBar', , 「分機 'Ext.data *'。 device.Connection' ], – user2427457

+0

在每個視圖中都有一個用於「requires」的配置 - 當您編譯/構建應用程序時這是必需的,這樣可以將依賴關係捆綁在一起 – arthurakay

+0

謝謝,實際情況是這樣,但我放只需要在app.js中,它已經足夠了,再次感謝。Eli。(PS不知道爲什麼它不需要在Android中?) – user2427457