views:

173

answers:

1

I am using a ABPersonViewController & ABNewPersonViewController class by pushview controller. ABPersonViewController *pvc = [[ABPersonViewController alloc] init]; [pvc setPersonViewDelegate:self]; [[self navigationController] pushViewController:pvc animated:YES]; In ABPersonViewController & ABNewPersonViewController page it is displaying in portrait mode. But when I rotate my iphone then it is perfectly rotating in landscape mode. But I want to stop this rotation. If I rotate my iphone in landscape mode it's view should be in portrait mode. Please help me ASAP. Any suggestion will be acepted.

A: 

Hello Andy,

The solution for your problem is quite simple: just subclass UINavigationController like this:

@interface UINonRotatingNavigationController : UINavigationController {
}
@end

in your .h file, and in your .m file type:

@implementation UINonRotatingNavigationController {

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
     return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Use it as your main navigation controller for the person picker - this should block it from rotating.

Hope this was helpful, Paul

Pawel
I tried this one before I post this question. But not solving the issue. Another things that ..If you implement in this way,you can't get the edit option in navigation barThanks for reply
Hi Paul,If you have done this things pls send me the sample code.Otherwise what you are commenting pls implement and test. what you told that is right or not? And also test the edit option is coming or not.I am waiting for your comments...............
Hey Andy, I've posted updated solution, Cheers
Pawel
Thanks for the reply. It is working perfectly. Once again thanks to you.