在ios 7中的ABPeoplePickerNavigationController中添加barButtonItems

时间:2013-10-17 09:10:22

标签: iphone ios ios7

您好,在我的iPhone应用程序中,我需要在ABPeoplePickerNavigationController中设置barButtonItems。在ios 6中它运行良好:

-(void) manageContacts
{
    peopleNavigationController = [[PeoplePickerNavigationController alloc] init];
    peopleNavigationController.peoplePickerDelegate = self;
    [peopleNavigationController.navigationBar setBarStyle:UIBarStyleBlack];

    peopleNavigationController.delegate = self;
    peopleNavigationController.topViewController.navigationItem.leftBarButtonItem =
    [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"back",nil)
                                     style:UIBarButtonItemStyleBordered
                                    target:self
                                    action:@selector(pressBack)];
    peopleNavigationController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addPerson)];

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


}

但在ios 7中有默认按钮。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我认为这是因为topViewController的{​​{1}} nil ,您可能需要将初始化的VC设置为navigationController的rootViewController。