谢谢大家。我发现真正有效的代码。它看起来像:UIBarButtonItem操作不起作用。为什么?
- (void)viewDidLoad {
[super viewDidLoad];
UIButton* infoButton = [UIButton buttonWithType: UIButtonTypeInfoLight];
[infoButton addTarget:self action:@selector(settingsClick) forControlEvents:UIControlEventTouchDown];
UIBarButtonItem* theSettingsButton =[[UIBarButtonItem alloc]initWithCustomView:infoButton];
[self.toolbar setItems:[NSArray arrayWithObjects:theSettingsButton,nil]];
[theSettingsButton release];
}
究竟什么是问题呢?代码是否编译?按钮出现了吗?按下它什么都不做?按下它会导致你的应用程序崩溃? – deanWombourne 2011-06-16 11:18:02
是什么,如果你做'NSLog(@“%@”,self.toolBar)'是'无';你有没有在界面生成器中正确连线? – deanWombourne 2011-06-16 11:20:59