【问题标题】:How to stop rotation of ABPersonViewController & ABNewPersonViewController in Landscape mode in iphone如何在 iPhone 的横向模式下停止 ABPersonViewController 和 ABNewPersonViewController 的旋转
【发布时间】:2010-05-09 11:42:19
【问题描述】:

我正在通过 pushview 控制器使用 ABPersonViewControllerABNewPersonViewController 类。

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

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

【问题讨论】:

    标签: iphone rotation screen-orientation abaddressbook


    【解决方案1】:

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

    @interface UINonRotatingNavigationController : UINavigationController {
    }
    @end
    

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

    @implementation UINonRotatingNavigationController {
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
         return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    
    @end
    

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

    希望这有帮助, 保罗

    【讨论】:

    • 我在发布这个问题之前尝试了这个。但不能解决问题。另一件事..如果您以这种方式实现,您将无法在导航栏中获得编辑选项 感谢您的回复
    • 嗨,保罗,如果您已经完成了这些操作,请将示例代码发送给我。否则,您所评论的内容请实施和测试。你说的是对还是错?并测试编辑选项是否到来。我在等待你的cmets......
    • 感谢您的回复。它运行良好。再次感谢您。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-29
    • 1970-01-01
    • 2012-11-10
    • 1970-01-01
    • 1970-01-01
    • 2011-10-05
    相关资源
    最近更新 更多