我正在使用这些方法来定义 navigationItem 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 它不会崩溃