在 UIBarButtonItem setTintColor 上发送的无法识别的选择器
我在应用程序商店中有一个正在使用 Flurry 分析的应用程序。而且我时不时地收到未处理的异常错误,但我无法弄清楚。
NSInvalidArgumentException:-[UIBarButtonItem setTintColor:]:无法识别的选择器发送到实例 0x177b20 消息:应用程序崩溃
我不明白的是,我没有在任何地方设置任何栏按钮项目色调颜色。我有一些自定义视图,我在其中设置右栏按钮项目,但没有色调。
我对按钮的大多数使用都是这样的。
- (void)viewDidLoad
{
[super viewDidLoad];
UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor colorWithRed:0 green:69.0/255 blue:118.0/255 alpha:1]];
self.navigationItem.title = @"Edit User";
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
initWithTitle:@"Save"
style:UIBarButtonItemStylePlain
target:self
action:@selector(editUser:)];
self.navigationItem.rightBarButtonItem = saveButton;
[saveButton release];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel)];
[[self navigationItem] setLeftBarButtonItem:cancelButton];
[cancelButton release];
}
如果有人对这个问题有任何见解,我将非常感激。我的项目目标是 iOS 4.0 及更高版本。
更新: 我找出了导致 setTintColor 上一些随机问题的原因。我发现我正在实际的栏按钮项目之一上设置色调颜色。我猜测操作系统版本之间存在一些差异,可能会导致崩溃。因此,如果有人能告诉我一种在导航栏中设置自定义右栏按钮项目的操作系统中立的方法,我将不胜感激。
I have an app in the app store that I'm using Flurry analytics on. And I keep getting an unhandled exception error from time to time that I can't figure out.
NSInvalidArgumentException: -[UIBarButtonItem setTintColor:]: unrecognized selector sent to instance 0x177b20
Msg: Application crashed
What I can't figure out is, I'm not setting any bar button items tint color anywhere. I have a few custom views where I am setting the right bar button item, but no tint.
Most of my uses of the button look like this.
- (void)viewDidLoad
{
[super viewDidLoad];
UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor colorWithRed:0 green:69.0/255 blue:118.0/255 alpha:1]];
self.navigationItem.title = @"Edit User";
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
initWithTitle:@"Save"
style:UIBarButtonItemStylePlain
target:self
action:@selector(editUser:)];
self.navigationItem.rightBarButtonItem = saveButton;
[saveButton release];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel)];
[[self navigationItem] setLeftBarButtonItem:cancelButton];
[cancelButton release];
}
If anyone has any insight into this issue, I would be very grateful. I am targeting iOS 4.0 and up in my project.
UPDATE:
I figured out what was causing some of the random issues on the setTintColor. I found that I was setting the tint color on one of the actual bar button items. I'm guessing there are some differences between OS versions that can cause crashes. So if anyone can tell me an OS neutral way of setting a custom right bar button item in my navigation bar, it would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题在于 2 个类上错误的 -setTintColor 使用。 -setTintColor 在 4.x 设备上不受支持,因此当旧设备遇到色调颜色时,您将会崩溃。
The problem was with errant -setTintColor usage on 2 classes. -setTintColor is not supported on 4.x devices, so you will crash when older devices bump into the tint color.
你尝试过吗:
?
Have you tried :
?
如果您的目标是 iOS 4.0,您可以这样做:
在您的 AppDelegate.m 中,@end 之后最后放置以下代码:
希望有所帮助。对我来说这是工作。
if your target is iOS 4.0 you can do this:
In your AppDelegate.m in the end after @end put this code:
Hope this help. For me it's work.