如何在按下按钮时让UINavigationController
显示提示?我已经按[[[self navigationController]navigationItem]setPrompt:[NSString stringWithFormat:@"Prompt is working!"]];
编辑:
为了澄清,我有一个调用IBAction
的按钮,它按如下方式设置提示,但是我需要找到一种方法来在按下该按钮时立即显示提示:
-(IBAction)test:(id)sender
{
[[[self navigationController]navigationItem]setPrompt:[NSString stringWithFormat:@"Prompt works!"]];
//I want it to display right after I set it, so I'm missing something and can't figure it out through the documentation
}
我已经尝试了[[[self navigationController]navigationBar]pushNavigationItem:nav animated:YES];
,但会引发错误,说明Cannot call pushNavigationItem:animated: directly on a UINavigationBar managed by a controller.
答案 0 :(得分:21)
您应该像下面这样设置提示文字:
self.navigationItem.prompt = @"This is the title";