这是我的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
, 什么都没发生。没有错误,没有。我设置了一个断点,但它永远不会到达选择器引用的方法。
我调用选择器的方式是否做错了什么?
Thanks!
您的按钮的声明缺少一些东西,即target
范围。尝试这个:
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"+ Contact"
style:UIBarButtonItemStylePlain
target:self
action:@selector(showPicker:)];
[self.navigationItem setLeftBarButtonItem:item animated:YES];
这假设showPicker:
事实上,与将按钮添加到导航项的类位于同一类中。
The target
参数是应该处理事件的实例。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)