【发布时间】:2011-07-12 18:55:49
【问题描述】:
这是我的UIBarButton:
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc]
initWithTitle:@"+ Contact"
style:UIBarButtonItemStylePlain
target:nil
action:@selector(showPicker:)] animated:YES];
这是它应该启动的代码:
- (void)showPicker:(id)sender {
ABPeoplePickerNavigationController *picker =
[[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
当我启动应用程序并单击“+ 联系人”UIBarButton 时,没有任何反应。没有错误,纳达。我放了一个断点,它永远不会到达选择器引用的方法。
我在调用选择器的方式上做错了吗?
谢谢!
【问题讨论】:
-
只要
showPicker确实有一个参数,选择器就可以了。 -
解决方案是
target = self,而不是target = nil。
标签: objective-c ios xcode uinavigationcontroller uibarbuttonitem