1

我想我可能将过多的正常上下文(网络应用程序开发)应用到使用 Titanium 的新移动项目中。我有一个包含几个按钮的主屏幕。我需要每个按钮打开一个包含全新内容的新窗口。在我的脑海中,我只是假设窗口会像请求或页面一样工作,因为创建和打开新窗口将完全用新内容替换现有内容。情况似乎并非如此(或者我正在做一些可怕的、可怕的错误)。在我的主屏幕上,这是一个按钮的事件处理程序:

btn_er_app.addEventListener( 'click', function( e ) {
    var win = Ti.UI.createWindow({
        bottom: 0,
        title: 'Next "Page"',
        top: 0,
        url: 'next_page.js',
    });
    win.open({ animated: true });
});

我的next_page.js页面看起来像这样(片段):

var win = Ti.UI.currentWindow;
win.layout = 'vertical';

var header = Ti.UI.createView({
    backgroundColor: '#f00', 
    height: 60,
    top: 0, 
});
win.add( header );

var body = Ti.UI.createView({
    backgroundColor:'#000',
    backgroundImage: '/images/body.png',
});
var label = Ti.UI.createLabel({
    text: 'Page Bits Go Here',
    textAlign: 'center',
});
body.add( label );

win.add( body );

我发现主屏幕内容仍然可见。显示红色标题块,但不显示正文视图。我试过设置 properties: height: '100%', bottom: 0height: 'auto'甚至将新窗口的fullscreen值设置为 true,但没有任何效果。

首先,“链接”在移动领域是如何运作的?我真的认为我的整个思考过程都需要重新调整,其次,我需要做什么才能让我的新窗口完全遮住底层的主屏幕窗口?

谢谢你的帮助。

4

1 回答 1

1

您不应该更换窗口,而是实际创建一个新窗口,然后让它打开。

根据您要实现的目标,您可能应该创建一个模式窗口。

就是这样:

var newWin = Ti.UI.createWindow({
    modal: true,
    title: 'new Window',
    navBarHidden: false
});

// adding a button to close the window again:

var button = Ti.UI.createButton({
    title: 'Close'
});

button.addEventListener('click',function(){
    newWin.close();
    newWin.hide();
});

win.leftNavButton = button;

newWin.open();

使用此窗口,您可以做各种事情,并添加您的视图等。

于 2011-10-14T17:23:53.583 回答