문제

I am writing an application that is based on UIViewController. It does not have a navigation bar. My application works with AddressBook. For now I use two things.

The first (select a people):

{
    ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
    picker.peoplePickerDelegate = self;
    [self presentModalViewController:picker animated:YES];
}

and the second (select a phone):

{
    ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
    picker.personViewDelegate = self;
    picker.displayedPerson = person;
    picker.displayedProperties = [NSArray arrayWithObjects: [NSNumber numberWithInt:kABPersonPhoneProperty], nil];
    [self presentModalViewController:picker animated:YES];
}

They are called in different functions.

In the first case when picker is displayed, it has a navigation bar with some buttons: Cancel etc.

In the second case another picker does not have a navigation bar. So, if I select the phone then it works but if I want to return without making a choice - I do not have a button "Back" or "Cancel".

How can I add the navigation bar in the second case?

I have tried to add another navigation controller and a viewcontroller as described below

How to correctly use ABPersonViewController with ABPeoplePickerNavigationController to view Contact information?

this display the navigatiob bar but my application crashes after this.

and

도움이 되었습니까?

해결책

ABPeoplePickerNavigationController, as the name suggests, is a navigation controller, so it has a navigation bar. ABPersonViewController is just a view controller, so it doesn't have a navigation bar of its own. You can put the instance of ABPersonViewController into a navigation controller yourself and present that, then it will have a navigation bar and you can add any buttons you need.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top