English 中文(简体)
在Appcelerator Titanium应用程序中打开另一个窗口不起作用
原标题:Opening another window in an Appcelerator Titanium-app doesn t work

I ve got basically 5 windows in my iPad-application (created with Appcelerator Titanium) and want to be able to navigate forth and back (a back and and a next-button for that purpose). The following approach doesn t work. Nothing happens upon clicking the button.

在我的app.js中,第一个窗口是这样打开的:

var window = Titanium.UI.createWindow({
    url: mainwindows.js ,
    modal: true
});
window.open();

然后在mainwindows.js中,我有一个名为next的按钮,它可以执行以下操作:

buttonNext.addEventListener( click , function(e){

        var newWindow = Titanium.UI.createWindow({
            url: "step_1.js",
            title: "Step 1"
        });
        win.open(newWindow, { animated:true})
});
最佳回答

您应该创建NavigationGroup可以这样操作您的窗口:

//root window for nav group — your modal
var rootWindow = Titanium.UI.createWindow({
    url: mainwindows.js ,
    modal: true
});

var navGroup = Ti.UI.iPhone.createNavigationGroup({
    window:window //your window (mainwindow.js)
});

rootWindow.add(navGroup);

//event handler
buttonNext.addEventListener( click , function(e){
    var newWindow = Titanium.UI.createWindow({
        url: "step_1.js",
        title: "Step 1"
    });
   navGroup.open(newWindow);
});

rootWindow.open();

浏览KitchenSink,有很多例子,包括NavigationGroup。

问题回答

这是我博客中的一个完整来源的例子,

http://blog.clearlyinnovative.com/post/4043980803/titanium-appcelerator-quickie-minimal-ipad-splitview

它在iPad上使用NavigationGroup。

我建议对你的项目进行清理并彻底重建

清理您的项目,然后再次运行。这无疑解决了完全出乎意料的“奇怪”问题。我最喜欢的一个是:

表达式Ti.UI.iPhone〔undefined〕的结果不是对象。

当您声明var navGroup时,window应设置为window:rootWindow,而不是windows:window





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签