【发布时间】:2012-06-15 20:00:48
【问题描述】:
注意:我只在模拟器上测试过。
我想在代码中添加目标操作,而不是在 Interface Builder 中将其连接为 IBAction。
theButton 位于左上角的导航栏上,在 IB 中创建。
步骤:
将
theButton声明为 IBOutlet 并在 IB 中连接。-
添加到
viewDidLoad:self.theButton.target = self; self.theButton.action = @selector(theAction); -
我正在通过这个测试
theAction:- (void)theAction { NSLog(@"theAction called"); //do some other stuff }
当我在模拟器中点击theButton 时,什么也没有发生。我根本没有看到 NSLog 语句。
我错过了什么?
【问题讨论】:
标签: iphone ios cocoa-touch uibarbuttonitem