2

In my implementation, I will change the title of the page after triggering some method

//In viewdidload of my view controller which resides in a navigation controller
-(void)viewDidLoad
{
    self.title = @"Title A";
}


-(void)changeTitle
{
    self.title = @"Title B";
}

In the above example, after I trigger the 'changeTitle' method, I do not see my viewcontroller's title change immediately. In fact I need to push another viewcontroller onto the stack and subsequently press 'back' before I see the change to "title B".

Is there any way to refresh the navbar's title at the point where I change title?

4

3 回答 3

0

我猜你正在寻找:

UrNavController.navigationBar.topItem.title = @"bkjasdkahsdflkjadf";

您可以在按下按钮后重置它。

您还可以为该主题分配一些其他对象,例如段控件或 uilabel。

于 2011-10-06T12:21:24.550 回答
0

Objective-C

[self.navigationItem setTitle:@"XYZ"];

斯威夫特 4.2

self.navigationItem.title = "XYZ"
于 2019-01-25T14:03:47.350 回答
0

如果要刷新以前的 viewController 的标题,请使用

self.parent?.title = "Some Title"
于 2019-01-25T13:46:23.667 回答