【问题标题】:disable UIViewController content animating on iPhone rotation禁用 iPhone 旋转上的 UIViewController 内容动画
【发布时间】:2010-11-06 09:35:51
【问题描述】:

我需要像在标准 iPod.app 中那样实现我的 UIViewController 子类的行为:当设备从纵向旋转到横向时,UIViewController 的内容保持静止并在其上方添加新视图。

问题是,当设置时

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

内容正在旋转

但是当设置时

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

功能

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    NSLog(@"did rotate form interface orientation %d",fromInterfaceOrientation);
}

是较新的称呼

那么,你知道如何在 UIViewController 中处理设备旋转而不旋转它的内容吗?

【问题讨论】:

    标签: iphone cocoa-touch iphone-sdk-3.0 uiviewcontroller


    【解决方案1】:

    实际上,您不希望您的 viewController 响应界面方向旋转。

    相反,只观察 UIAccelerometer 通知更容易。然后进行视图的完全交换。

    您可以在 SO 上查看执行此操作的代码:

    Rotating the iPhone, and instantiating a new UIViewController?

    UIDevice Orientation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-27
      • 1970-01-01
      • 2012-07-21
      • 2011-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多