开发者

iPhone how to get the title for a custom Back-Button

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 o开发者_StackOverflowf 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?


The title of the back button is always the title of the 2nd top view controller.

Thus you can use (after ensuring there are ≥2 view controllers):

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

If you're going for a green button, why not simply set the nav bar's tint to green?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜