如何将leftBarButtonItem添加到ABPeoplePickerNavigationController?

时间:2009-10-25 09:13:56

标签: iphone

试过这个,但不起作用:

ABPeoplePickerNavigationController * people_picker = [[ABPeoplePickerNavigationController alloc] init];

people_picker.peoplePickerDelegate = self;

self.navigationController.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle: @"send" 
       style: self.navigationController.navigationItem.rightBarButtonItem.style
      target: self
      action: @selector(cancelAddressBook)] autorelease];

[self.navigationController presentModalViewController: people_picker animated: YES];

2 个答案:

答案 0 :(得分:4)

您应该设置新创建的人员选取器控制器的topViewController的leftBarButtonItem。

ctrl.topViewController.navigationItem.leftBarButtonItem = ...

答案 1 :(得分:1)

由于人物选择器是模态视图,您需要直接向其添加按钮,而不是向导航控制器添加。试试这个:

people_picker.navigationBar.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle: @"send" 
   style: self.navigationController.navigationItem.rightBarButtonItem.style
  target: self
  action: @selector(cancelAddressBook)] autorelease];