开发者

How to stop rotation of ABPersonViewController & ABNewPersonViewController in Landscape mode in iphone

I am using a ABPersonViewController and ABNewPersonViewController class by pushview controller.

 ABPersonViewController *pvc = [[ABPersonViewController alloc] init];
 [pvc setPersonViewDelegate:self];
 [[self navigationController] pushViewController:pvc animated:YES];

In ABPersonViewController and ABNewPersonViewController page it is displaying in portrait mode. But when I rotate my iPhone then it is perfectly rotating i开发者_JAVA百科n 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.


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜