gpt4 book ai didi

iphone - 使用 UIBarButtonItemStyle 创建一个 UIBarButtonSystemItem

转载 作者:行者123 更新时间:2023-11-28 23:13:35 28 4
gpt4 key购买 nike

我想创建一个系统 UIBarButton,但我希望它具有简单的样式。
我试过这段代码,但样式被忽略了。有什么问题吗?

UIBarButtonItem *search = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(showSearch)];    
search.style = UIBarButtonItemStylePlain;
self.navigationItem.rightBarButtonItem = search;
[search release];

最佳答案

这里最主要的是您需要将按钮放在前一个 Controller 中,而不是将要按下的 Controller 中。

//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];

关于iphone - 使用 UIBarButtonItemStyle 创建一个 UIBarButtonSystemItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7351202/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com