【问题标题】:Nativescript page title not rendering when set after navigation导航后设置时,Nativescript 页面标题不呈现
【发布时间】:2016-03-24 03:09:52
【问题描述】:

我正在构建一个应用程序,但在导航到该页面后在 ActionBar 中呈现标题时出现问题。由于 ActionBar 不能有一个 id 我使用可观察的 viewModel 在其中我设置了 title 属性。

-----xml-----
    <Page.actionBar>
        <ActionBar title="{{ name }}">
        </ActionBar>
    </Page.actionBar>
-------------
------js-----

  exports.pageLoaded = function(args) {
    page = args.object;

    var navData = page.navigationContext;
    viewModel.set("name",navData.name);

    page.bindingContext = viewModel;
};

到目前为止,我在调试此问题时所看到的是,当我关闭手机屏幕然后打开它(刷新应用程序)时,将呈现操作栏标题。

找到答案(一种解决方法),

 <ActionBar> 
        <ActionItem ios.systemIcon="12" android.systemIcon="ic_menu_search" tap="showSearch" /> 
    <ActionItem android.systemIcon="ic_menu_moreoverflow" tap="logout" text="Logout" android.position="popup" /> 
    <ActionBar.titleView> 
           <StackLayout orientation="horizontal"> 
           <Label text="{{ name }}" /> 
           <Image src="res://app_icon" /> 
           </StackLayout> 
    </ActionBar.titleView> 

【问题讨论】:

  • 这也发生在我的应用程序中。前往 GitHub 并提出问题!
  • 这应该从导航到完成。你可以这样做page.actionBar.title="i am a title"

标签: nativescript


【解决方案1】:

您需要在不同的页面事件中设置标题,相当肯定您应该在页面的navigatedTo 事件中执行此操作。

有关页面导航事件的更多信息,请查看此博文Nathanael Anderson - FluentReports - page navigating order of events

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-22
    • 2019-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多