导航控制器显示提示

时间:2011-11-02 21:35:59

标签: iphone objective-c uinavigationcontroller

如何在按下按钮时让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.

1 个答案:

答案 0 :(得分:21)

您应该像下面这样设置提示文字:

self.navigationItem.prompt = @"This is the title";