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

余生颓废 提交于 2019-12-08 12:56:36

问题


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 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.


回答1:


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



来源:https://stackoverflow.com/questions/2797515/how-to-stop-rotation-of-abpersonviewcontroller-abnewpersonviewcontroller-in-la

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!