标签:style blog color os strong io for cti
(ios6.1)有两个controller在navigation stack里,A和B。A是B的previous view controller,现在top-level controller是B。要自定义B的backBarButtonItem。
在B的viewDidLoad里添加:
1 //chage navigationBarButton 2 UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"房间选择" style:UIBarButtonItemStyleDone target:nil action:nil]; 3 [self.navigationItem setBackBarButtonItem:backButtonItem];
试了,结果还是默认的back按钮。
UINavigationController Class Reference中有段话:
The bar button item on the left side of the navigation bar allows for navigation back to the previous view controller on the navigation stack. The navigation controller updates the left side of the navigation bar as follows:
1、如果B视图有一个自定义的左侧按钮(leftBarButtonItem),则会显示这个自定义按钮;
2、如果B没有自定义按钮,但是A视图的backBarButtonItem属性有自定义项,则显示这个自定义项;
3、如果前2条都没有,则默认显示一个后退按钮,后退按钮的标题是A视图的标题,或者默认
try again,在A中的ViewDidLoad中定义backButtonItem:
1 //chage navigationBarButton 2 UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"房间选择" style:UIBarButtonItemStyleDone target:nil action:nil]; 3 [self.navigationItem setBackBarButtonItem:backButtonItem];
发现B中的backBarButtonItem改变了!!!
如果在B中custom一个UIbarButtonItem,赋值给self.navigationItem.leftBarButtonItem,那么这个UIBarButtonItem将替换backBarButtonItem按钮。
关于Navigation的BarButtonItem的,布布扣,bubuko.com
标签:style blog color os strong io for cti
原文地址:http://www.cnblogs.com/hereiam/p/3888599.html