2012-02-10 69 views
0

当我在Sencha Touch应用程序中的视图之间移动时,看到动画(幻灯片),然后再次显示原始视图(我开始的视图)。此时,如果我点击应用程序中的任何位置,视图将更改为正确的新活动项目。Sencha Touch setActiveItem显示动画,然后需要点击以显示

我正在使用Sencha Touch,XCode 4,iOS 5 SDK和PhoneGap 1.3.0。

在此先感谢!

这里的主视代码:

plantanalyzer.views.Viewport = Ext.extend(Ext.Panel, { 
fullscreen: true, 
layout: 'card', 
cardSwitchAnimation: 'slide', 
initComponent: function() { 
Ext.apply(plantanalyzer.views, { 
      login: new plantanalyzer.views.Login(), 
      plantDetail: new plantanalyzer.views.PlantDetail(), 
      buildingList: new plantanalyzer.views.BuildingList() 
      }); 
Ext.apply(this, { 
      items: [ 
        plantanalyzer.views.login, 
        plantanalyzer.views.plantDetail, 
        plantanalyzer.views.buildingList 
        ] 
      }); 


    plantanalyzer.views.Viewport.superclass.initComponent.apply(this, arguments); 
    } 
}); 

,为的viewController:

plantanalyzer.controllers.viewController = new Ext.Controller({ 
index: function(options) { 
    plantanalyzer.views.viewport.setActiveItem(plantanalyzer.views.plantDetail, options.animation); 
}, 
show: function(options) { 
    plantanalyzer.views.viewport.setActiveItem(plantanalyzer.views.buildingList, 

options.animation); 
    } 
}); 

,这是其中一个视图代码:

plantanalyzer.views.PlantDetail = Ext.extend(Ext.Panel, { 
width: 320, 
height: 480, 
items: [ 
    { 
     xtype: 'panel', 
     html: '<img src="images/logo.jpg"/>', 
     tpl: '{name}', 
     cls: 'plantToolbar' 
    }, 
    { 
     xtype: 'button', 
     name : 'buildingSelect', 
     text: 'Select Building', 
     cls: 'standardButton', 
     listeners: { 
      'tap': function() { 
       'use strict'; 
       Ext.dispatch({ 
        controller: plantanalyzer.controllers.viewController, 
        action: 'show' 
       }); 
      } 
     } 
    }, 
    { 
     xType: 'panel', 
     cls: 'infoBoxes', 
     html: 'Efficiency (kw/ton)<br><canvas id="eff"></canvas>' 
    }, 
    { 
     xType: 'panel', 
     cls: 'infoBoxes', 
     name: 'totalTons', 
     html: 'Total Plant Tons: ' 
    }, 
    { 
     xType: 'panel', 
     cls: 'infoBoxes', 
     name: 'totalCost', 
     html: 'Real-time Plant Cost: ' 
    }, 
    { 
     xType: 'panel', 
     name: 'uodateTime', 
     cls: 'lastUpdate', 
     html: 'Last Update: ' 
    } 
    ] 
}); 

回答

1

的代码在两个部分看起来都很好。当我遇到phonegap和sencha触摸问题时,我通常会发现有一个javascript错误发生,或者index.html文件的body标签之间存在额外的html标记。第一件事是在Chrome或Safari浏览器中打开控制台,并检查javascript控制台以确定它是否是JavaScript错误。如果你不能运行它,我会建议Wienre应用程序,它会给你一个控制台,并被写入调试phonegap应用程序(wienre也将允许您查看html标记,以确保它是正确的)

+0

谢谢!我正在查看它。我会让你知道我找到了什么。 – kevinstueber 2012-02-10 19:30:16

+0

没有运气,与Weinre检查错误,通过JSLint运行所有JS文件,并通过HTMLlint运行我的index.html。没有领导......任何其他想法? – kevinstueber 2012-02-10 22:36:36

1

问题必须在视图文件中的某处。你所显示的代码是正确的。

+0

谢谢,我更新了问题以包含示例视图... – kevinstueber 2012-02-11 14:00:17

0

那么,为什么它的价值,重建应用程序后,我发现这个问题。这是一些自定义的CSS,搞砸了应用程序。特别是在某些组件上设置的宽度。希望这会为别人节省一些时间和心痛。

谢谢Darren和Ilija的帮助!