0
我使用這個方法來定義navigationItem rightBarButtonItems:應用程序崩潰時,試圖定義rightBarButtonItems
UIImageView * imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"YouTube-icon"]];
UIBarButtonItem *barIcon = [[UIBarButtonItem alloc]initWithCustomView:imageView];
if ([videoArr count] > 0) {
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:barIcon,self.aToZButton, nil];
} else {
self.navigationItem.rightBarButtonItem = barIcon;
}
[imageView release];
[barIcon release];
而當調試是:
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:barIcon,self.aToZButton, nil];
的應用程序崩潰與:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType isSystemItem]: unrecognized selector sent to instance 0x1e5eecd0'
編輯
我注意到,只有當我使用rightBarButtonItem然後rightBarButtonItem時發生崩潰。 如果我只使用rightBarButtonItems它不會崩潰
爲什麼要釋放兩次imageView? – Levi
這是錯誤的,我編輯代碼 – MTA
顯示你的代碼爲aToZButton以及 – NightFury