1

Heyho, I'm building a custom green back button which is being created in the "viewDidAppear:" method.

I don't have any problems with the "getting-it-into-the-Navigationbar" or with "popping-the-current-View", but my Problem is:

How do I get the title of the previous controller, so I can set it as Lable for the custom Back Button? And is there a way to know if there even is any?

4

2 回答 2

3

后退按钮的标题始终是第二个顶视图控制器的标题。

因此您可以使用(在确保有≥2个视图控制器之后):

NSArray* viewCtrlers = self.navigationController.viewControllers;
UIViewController* prevCtrler = [viewCtrlers objectAtIndex:[viewCtrlers count]-2];
return prevCtrler.title;

如果您想要一个绿色按钮,为什么不简单地将导航栏的色调设置为绿色呢?

于 2010-03-05T13:39:11.223 回答
1

This is handled for you automatically. Just set the title of each view, and the UINavigationController takes care of the back button labels for you

于 2010-03-05T13:36:40.080 回答