开发者

ABPersonViewController drawn under the navgation bar

开发者 https://www.devze.com 2023-01-22 04:04 出处:网络
The context: I am working on an app that maintains a list of contacts along with their record IDs for it\'s own reference.

The context:

I am working on an app that maintains a list of contacts along with their record IDs for it's own reference.

When the user needs to change the number associated with a specific contact within the app, I am trying to display the ABPersonViewController so the user can choose the new number from the contact in AB.

The problem: The problem is that the ABPersonViewController that is opened is starting all the way from the top of the screen as if it does not know that there is a navigation bar on the top.

As a result some of the top part of the ABPersonViewController screen (the top part of the person image and the top part of the name) is underneath the navigation bar.

Ideally i want it to look like this, but not in edit mode: http://developer.apple.com/library/ios/d开发者_如何学编程ocumentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Art/person_view.jpg

Also I wanted to add a "cancel" button to the top right part of the nav bar. Trying to add that as a bar button is not working either.

The code: this is how I am adding the ABPersonViewController to the navigationController:

ABPersonViewController *personViewController = [[ABPersonViewController alloc] init];
personViewController.personViewDelegate = self;
personViewController.displayedPerson = person; 
[self.m_circleNavController pushViewController:personViewController animated:YES];
[personViewController release];

The self here is a UIVIewController.

The m_circleNavController is the UINavigationController to which the UIVIewController belongs.

I tried these 2 ways of showing the person view, but both behave the same way.

[self.m_circleNavController pushViewController:personViewController animated:YES];

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

I'm not too sure what I am doing wrong, or what is the best way to do it. I tried a lot of different ways to display it in vain.


The viewcontroller was behaving as though it was starting about 40 pixels above the top edge of the screen.

I was able to fix it in a very weird way finally. In the init function of the viewcontroller I added the following line:

self.view.bounds = CGRectMake(0, -43, 320, 440);

But still no clue as to why it happens this way. I was to close to the deadline to look for a decent solution.


Hello I've been having the same problem as of the new iOS. When this happens on my custom view controllers I have been able to correct it with:

if (self.interfaceOrientation != UIInterfaceOrientationPortrait) {  // UI is in landscape position

        [self.tableView setContentInset:UIEdgeInsetsMake(32,0,0,0)]; 
    } else { // UI is in portrait position

        [self.tableView setContentInset:UIEdgeInsetsMake(44,0,0,0)]; 
    }

But when using the ABPersonViewController I don't quite know how to handle this problem. Hope someone has an idea...

0

精彩评论

暂无评论...
验证码 换一张
取 消