PJR
PJR

Reputation: 13180

add navigationbar in ABUnknownPersonViewController

ABUnknownPersonViewController *unknownPersonViewController = [[ABUnknownPersonViewController alloc] init];

unknownPersonViewController.view.frame = CGRectMake(0, 20, 320, 400);

//unknownPersonViewController.displayedPerson = (ABRecordRef)[self buildContactDetails];
unknownPersonViewController.allowsAddingToAddressBook = YES;

UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
cancelBtn.frame = CGRectMake(262, 6, 54,30);
[unknownPersonViewController.view addSubview:cancelBtn];

[self presentModalViewController:unknownPersonViewController animated:YES];

[unknownPersonViewController release]; 

i am using UIViewcontroller and in this code i want that a bar like navigation bar will show in upper side of this controller so i want to put cancel button on that bar.any help?

Upvotes: 0

Views: 1038

Answers (2)

Rob
Rob

Reputation: 438122

Hmm, the online documentation says "Important Unknown-person view controllers must be used with a navigation controller in order to function properly." So, unlike a lot of the utility view controllers, I don't think you should be invoking

[self presentModalViewController:unknownPersonViewController animated:YES];

But rather

[self.navigationController pushViewController:view animated:YES];

I think if you look at their samples, you'll see they push using the navigation controller.

Upvotes: 0

arclight
arclight

Reputation: 5310

What you should do is embed your ABUnknownPersonViewController in a UINavigationController

UINavigationController *newNavigationController = [[UINavigationController alloc] initWithRootViewController:unknownPersonViewController];

[self presentModalViewController:newNavigationController animated:YES];   
[view release];

[newNavigationController release];

That way you wouldn't even have to add the button yourself, the ABUnknownPersonViewController would take care of it for you.

For more info check Address Book Programming

Upvotes: 2

Related Questions