【问题标题】:Sencha Touch - switching between viewsSencha Touch - 在视图之间切换
【发布时间】:2012-05-23 13:07:06
【问题描述】:

我正在尝试使用 miamicode 制作相同的应用程序,我在第 3 步 http://miamicoder.com/2012/how-to-create-a-sencha-touch-2-app-part-3/

我尝试制作转到新笔记的按钮(切换到新屏幕并创建新笔记)

示例中的代码是这样的:

   onNewNoteCommand: function () {
   console.log("onNewNoteCommand");
   var now = new Date();
   var noteId = (now.getTime()).toString() + (this.getRandomInt(0, 100)).toString();
   var newNote = Ext.create("NotesApp.model.Note", {
          id: noteId,
            dateCreated: now,
            title: "",
            narrative: ""
        });

        this.activateNoteEditor(newNote);
    }

activateNotesList 函数是这样的:

activateNotesList: function () {

   Ext.Viewport.animateActiveItem(this.getNotesListView(), this.slideRightTransition);

在我自己的示例中,我尝试在不传递数据的情况下进入编辑视图。 所以我试试这个:

onNewNoteCommand:function()

{
var noteEditor = this.getNoteEditor();

 // Ext.Viewport.add(noteEditor);  also tried this.

Ext.Viewport.setActiveItem(noteEditor);

该代码运行没有错误,但屏幕没有改变。 有什么建议吗? add 有什么区别?

如何将视口(尚未创建任何自定义视口)设置为卡片?这是 setactiveitem 不起作用的问题吗?还有什么其他方式可以在视图之间切换吗?

【问题讨论】:

    标签: sencha-touch-2


    【解决方案1】:

    google chrome 浏览器的控制台是否有一些错误? Ctrl+Shift+J打开。

    您还必须检查 noteEditor 是否等于 Object 或 Number。

    来自 sencha 文档:setActiveItem( Object/Number activeItem )

    【讨论】:

    • 我没有错误。但是noteEditor的类型是不确定的......这就是我的noteEditor开始的方式:Ext.define(“noteditor.view.NoteEditor”,{extend:“Ext.form.Panel”,别名:“widget.noteeditor”,需要: “Ext.form.FieldSet”,配置:{布局:{type:'vbox'}},初始化:函数(){.....并且在控制器上我有一个参考Ext.define(“noteditor.controller.Notes ", {extend: "Ext.app.Controller", config: { refs: { notesListContainer: "Main", noteEditor: "noteeditor" }, control: { }},
    • 你应该这样写: Ext.define("noteditor.view.NoteEditor", { extend: "Ext.form.Panel", xtype: 'noteeditor'..... 和你的参考noteEditor 不会是未定义的。
    • console.log (typeof(this.noteEditor));我在按钮操作中输入了这个。还使用 xtype 更改别名。但没有运气......仍然未定义......我尝试了一些功能,它工作正常。也试过 typeof(noteditor.views.Notes) 我的观点不应该在那里吗?
    • 检查名称:noteditor.view.Notes 还是 noteditor.view.NoteEditor?你在你的名字或视图中使用视图(必须使用视图作为文件夹的名称,而不是视图等)。
    • 另外,学习 sencha touch 最好的方法是探索 sencha touch 2 example's code。比如oreilly、geocongress、touchtweets。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多