我想创建一个系统UIBarButton,但我希望它有简单的风格。
我已经尝试过这段代码,但是样式被忽略了。它有什么问题?
UIBarButtonItem *search = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(showSearch)];
search.style = UIBarButtonItemStylePlain;
self.navigationItem.rightBarButtonItem = search;
[search release];发布于 2011-09-09 00:24:38
找到一个类似的线程here。
似乎制定此计划的方法是创建您的自定义UIButton并将其分配给栏按钮。
发布于 2011-09-09 10:12:19
这里的主要问题是,您需要将按钮放在前一个控制器中,而不是放在要被按下的控制器中。
//Your actual ViewController
UIBarButtonItem *search = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(showSearch)];
search.style = UIBarButtonItemStylePlain;
self.navigationItem.rightBarButtonItem = search;
[search release];
//Controller that is going to be pushed and will display the new UIBarButtonItem
[self.navigationController pushViewController:newViewController animated:YES];https://stackoverflow.com/questions/7351202
复制相似问题