0

在我的基于钛的应用程序中,我的导航流程如下

HomeVu -> Subvu1 -> Subvu2

在尝试从 Subvu1 视图导航到 Subvu2 时,它显示一个错误

  Script Error 
  {
  backtrace = "#0 () at :0";
  line = 40;
  message = "'undefined' is not an object (evaluating 'ReportSubWindow.containingTab.open')";
  name = TypeError;
  sourceId = 300153536;
  sourceURL = "file:///Users/administrator/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/9A6B5752-F198-48AC-9E23-2A0DC31A2BD2/test.app/SubVu/text.js";
  } 

这里的代码

HomeVu

  button2.addEventListener('click', function() 
  {
    var FindAnExpertSubWindow = require('SubVu/email');
    self.containingTab.open(new FindAnExpertSubWindow('My Mail'));
  });

Subvu1

function FindAnExpertSubWindow(title) 
{
var findAnExpertSubWin = Ti.UI.createWindow({
    backgroundColor : 'white', });
var button1 = Ti.UI.createButton({
    backgroundImage: 'ui/images/Untitled.png',
    height:32,
    width:87,
    top:90,
    left:115,

});

button1.addEventListener('click', function() 
{
var FindAnExpertSubWindow = require('SubVu/email');
    findAnExpertSubWin.containingTab.open(new FindAnExpertSubWindow('My Mail'));
});
findAnExpertSubWin.add(button1);
return findAnExpertSubWin;
    };
 module.exports = FindAnExpertSubWindow; 

Subvu2

 function ReportSubWindow(title) 
 {
var reportSubWin = Ti.UI.createWindow({
backgroundColor : 'black',
    });
 return reportSubWin;
 };
 module.exports = ReportSubWindow; 

如何从 Subvu1 导航到 Subvu2?

4

1 回答 1

1

创建 Subvu1 窗口时,您必须像在 HomeVu 窗口中一样设置 containsTab 属性。您的代码示例缺少那部分代码,但可能看起来像这样:

HomeVu

button2.addEventListener('click', function() {
    var FindAnExpertSubWindow = require('SubVu/email');
    self.containingTab.open(new FindAnExpertSubWindow('My Mail', self.containingTab));
});

Subvu1

function FindAnExpertSubWindow(title, containingTab) {
    var findAnExpertSubWin = Ti.UI.createWindow({
        backgroundColor : 'white',
        containingTab: containingTab,
    });
    /* ... */
});

另一种解决方法是停止在每个 Window 之间传递对 Tab 对象的引用,只创建一个全局对象,您将使用它来打开新窗口。

如果没有帮助,请发布更多示例代码。

于 2014-03-20T20:44:26.223 回答