自定义后退按钮标题并保持向后滑动手势 [英] Custom back button title and keep the swipe back gesture
问题描述
问题:
我想在弹出的视图控制器中自定义导航后退按钮标题,如Whatsapp(< Chats(2)/< Chats(3))。
Problem : I would like to custom the navigation back button title in the popped view controller like Whatsapp ( < Chats (2) / < Chats (3) ).
但是,如果您使用
self.navigationController.interactivePopGestureRecognizer.delegate = self;
为了保持手势的正常运行,它会给你带来更多麻烦(过多的bug)。
to keep the gesture work, it will give you more troublessss (too many bugssss).
推荐答案
您必须在<$上设置 self.navigationItem.backBarButtonItem
属性c $ c> ViewController 在显示标题之前出现。
You have to set the self.navigationItem.backBarButtonItem
property on the ViewController
that comes before the one will show the title.
在Whatsapp示例中,您必须设置标题聊天列表视图控制器。
In the Whatsapp example, you will have to set the title on the chats list view controller.
类似的东西:
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"chats(2)" style:UIBarButtonItemStylePlain target:nil action:nil];
之后,您只需设置标题
self.navigationItem.backBarButtonItem
。
这篇关于自定义后退按钮标题并保持向后滑动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!