我在應用商店中有一個應用程序,我正在使用Flurry分析。我不時得到一個未處理的異常錯誤,我無法弄清楚。在UIBarButtonItem上發送無法識別的選擇器setTintColor
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的一些隨機問題的原因。我發現我在其中一個實際的條形按鈕項目上設置了色調顏色。我猜測操作系統版本之間可能會導致崩潰。因此,如果任何人都可以告訴我一個操作系統中立的方式來設置我的導航欄中的自定義右鍵按鈕項目,將不勝感激。
我最近遇到了一些問題。有時候,你必須在NavigationController的子視圖上調用setTintColor。 ([[[[self.navigationController.navigationBar subviews] objectAtIndex:1] setTintColor:[UIColor redColor]];)至少可以解決它。 – CodaFi