标签:os io ar for div 问题 cti 代码 html
在viewDidLoad里,为navigationItem添加名称为“添加分栏”的按钮
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationItem.rightBarButtonItem.title = @"添加分栏";
[self.navigationItem.rightBarButtonItem initWithBarButtonSystemItem:UIBarButtonSystemItemUndo
target:self
action:@selector(myAction)];
}
-(void)onSelectionChanged:(id)selection
{
self.navigationItem.rightBarButtonItem.title = @"编辑";
}为何直接设置backBarButtonItem的title无效呢?
查看苹果文档UIBarButtonItem的父类UIBarItem的title属性描述:
You should set this property before adding the item to a bar. The default value is nil.故无法修改其title,只能重置这个控件本身。
self.navigationItem.rightBarButtonItem.title = @"编辑"; [self.navigationItem.rightBarButtonItem initWithBarButtonSystemItem:UIBarButtonSystemItemUndo target:self action:@selector(myAction)];
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemUndo
target:self
action:@selector(changeWellColumnAction)];
temporaryBarButtonItem.title = @"编辑";
self.navigationItem.rightBarButtonItem = temporaryBarButtonItem;
[temporaryBarButtonItem release];iOS常见问题之动态修改UINavigationController的rightBarButtonItem的title
标签:os io ar for div 问题 cti 代码 html
原文地址:http://blog.csdn.net/wanglei9876/article/details/38932993