开发者

How do I create a window with a title, navbar and button bar?

开发者 https://www.devze.com 2023-03-07 11:11 出处:网络
I wish to create a window with a title bar and button bar but do not wish to use a tab group. I tried the following without success:

I wish to create a window with a title bar and button bar but do not wish to use a tab group.

I tried the following without success:

var win = Titanium.UI.createWindow({
    title: "Home",
    backgroundColor: '#bbb',
    navBarHidden:false
});
var b = Titanium.UI.createButton({
    title:'Button',
    style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
win.setToolbar([b]);
win.add(Titanium.UI.createLabel({text: "Label"}));
win.open();

Neither the toolbar or the title show, however if I place this content inside a TabGroup it functions as expected.

If I can't get this behaviour by default, could someone please demonstrate how to create a label (or button) using the system rendered style for the title and if its possible to do something similar to get the button bar at the bottom?

The following does work:

var win = Titanium.UI.createWindow({
    title: "Home",
    backgroundColor: '#bbb',
    navBarHidden:false
});
var b = Titanium.UI.createButton({
    title:'Button',
    style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
win.setToolbar([b]);
win.add(Titanium.UI.createLabel({text: "Label"}));
var tabGroup开发者_如何学JAVA = Titanium.UI.createTabGroup();
tabGroup.addTab(Titanium.UI.createTab({
    title:'Home',
    window:win
}));
tabGroup.open();


It seems I can get what I'm after by wrapping my window in another window using a navigation group:

var win = Titanium.UI.createWindow({
    title: "Home",
    backgroundColor: '#bbb'
});
var b = Titanium.UI.createButton({
    title:'Button',
    style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
});
win.setToolbar([b]);

var nav = Titanium.UI.iPhone.createNavigationGroup({
    window:win
});
var root = Titanium.UI.createWindow();
root.add(nav);
root.open();

I don't really need the navigation group, but it does what I'm after.

0

精彩评论

暂无评论...
验证码 换一张
取 消