0

我制作了简单的钛移动应用程序。起初我想在按下某个按钮时打开新窗口。当我使用模态窗口时,它可以显示一个标题栏,这样我就可以将返回按钮放在那里,如下所示:

在此处输入图像描述

这是我的代码:

    var MainMenu = require('ui/common/option2/MainMenu');

    var mainMenuWindow = Titanium.UI.createWindow({
        title:'Main Menu',
        backgroundColor:'white',
        modal:true,
        navBarHidden:Ti.Platform.osname ==='android' ? true : false
    });

    var mainMenu = new MainMenu(mainMenuWindow);
    mainMenuWindow.add(mainMenu);

    mainMenuWindow.open();

但是如果我清除modal:true标题栏不会像这样显示:

在此处输入图像描述

有谁知道在没有模式的情况下打开新窗口时如何显示/添加标题栏?我试过使用工具栏,但这真的很麻烦,因为我应该定义字体大小,甚至按钮的位置:(有什么建议吗?非常感谢..

4

2 回答 2

4

实际上,在不使用模式的情况下显示标题栏存在问题,因此这里是调整。

您必须添加一个选项卡组并将您的窗口添加到它的选项卡,并将该​​窗口的 `tabBarHidden' 设置为 true。

运行应用程序时,您将看到标题栏..

这是它的示例代码

var tabGroup = Ti.UI.createTabGroup();

var win = Ti.UI.createWindow({
  backgroundColor:'#fff',
  tabBarHidden:true
});

var tab = Ti.UI.createTab({
   window: win,
  title: 'my win'
});

tabGroup.addTab(tab);

tabGroup.open();

上述解决方案适用于 iOS。

对于 Android,这是诀窍:

将这些行添加到您的<app-project-dir>/platform/android/res/layout/titanium_tabgroup.xml文件中。

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="0dp">

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="0dp"
        android:layout_weight="1"/>

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="0"/>

</LinearLayout>

</TabHost>
于 2012-10-31T13:56:54.540 回答
-2

您已设置navBarHidden为 true。尝试这个:

var mainMenuWindow = Titanium.UI.createWindow({
    title:'Main Menu',
    backgroundColor:'white',
    modal:true,
    navBarHidden: false // always show nav bar
});
于 2012-10-19T11:54:53.917 回答