0

我正在通过 pushview 控制器使用一个ABPersonViewController和类。ABNewPersonViewController

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

在页面中ABPersonViewControllerABNewPersonViewController它以纵向模式显示。但是当我旋转我的 iPhone 时,它​​会在横向模式下完美旋转。但我想停止这种轮换。如果我在横向模式下旋转我的 iPhone,它的视图应该是纵向模式。

4

1 回答 1

1

您的问题的解决方案非常简单:只需像这样子类 UINavigationController :

@interface UINonRotatingNavigationController : UINavigationController {
}
@end

在您的 .h 文件和 .m 文件类型中:

@implementation UINonRotatingNavigationController {

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

@end

将它用作人员选择器的主要导航控制器 - 这应该阻止它旋转。

希望这有帮助,保罗

于 2010-05-09T11:56:42.803 回答