更改BarButtonItem的标题

时间:2013-10-04 08:00:08

标签: ios title uibarbuttonitem

我创建了从本地通知到questionViewController(在appDelegate.m中)的重定向:

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

 UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
 cysViewController *cvc =[sb instantiateViewControllerWithIdentifier:@"cysViewController"];
 questionViewController *qvc = [sb instantiateViewControllerWithIdentifier:@"questionViewController"];
 qvc.categoryId = @"339";
 UINavigationController *nav = (UINavigationController *) self.window.rootViewController;
 nav.viewControllers = [NSArray arrayWithObjects:cvc,qvc, nil];
 [(UINavigationController *)self.window.rootViewController popToViewController:qvc animated:YES];
 // back button appearance
 [[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:(107/255.0) green:  (11/255.0) blue:(47/255.0) alpha:1]];
}

一切正常。显示后退项目并更改其外观。我想改变后退按钮的标题,但我不知道该怎么做。我尝试了一些例子但没有成功。有没有人想改变后退按钮的标题?

3 个答案:

答案 0 :(得分:0)

你可以试试这个:

self.navigationItem.backBarButtonItem =  @"my title";

答案 1 :(得分:0)

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
     self.navigationController.navigationItem.backBarButtonItem.title = @"Title";
}

答案 2 :(得分:0)

cvc.navigationItem.title = @"Some Title";