开发者

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

开发者 https://www.devze.com 2022-12-29 12:06 出处:网络
I am using a ABPersonViewController and ABNewPersonViewController class by pushview controller. ABPersonViewController *pvc = [[ABPersonViewController alloc] init];

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

精彩评论

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

关注公众号