【问题标题】:Change view layout with orientation使用方向更改视图布局
【发布时间】:2010-02-02 16:27:51
【问题描述】:

我正在开发一个应用程序,我希望在设备旋转时视图会发生很大变化。我知道在 Interface Builder 中可以更改方向并在那里设置布局,但是当我将其旋转为纵向时,视图与横向视图相同。有没有办法独立设置两个视图,也许使用两个 nib?

干杯, JP

【问题讨论】:

    标签: iphone interface-builder view rotation


    【解决方案1】:

    如果您在改变方向后切换视图控制器,例如当 iPod 应用程序显示它的封面流视图时,以下帖子会有所帮助:

    http://rndnext.blogspot.com/2009_06_01_archive.html

    【讨论】:

      【解决方案2】:

      我不知道你是否可以在 IB 中做到这一点,但我知道你可以在代码中做到这一点。您需要观察 UIDeviceOrientationDidChangeNotification 通知:

      (在 viewDidLoad 中...)

      [[NSNotificationCenter defaultCenter] 
              addObserver:self 
              selector:@selector(updateViewOnRotate:)
              name:UIDeviceOrientationDidChangeNotification 
              object:nil];
      

      ....

      -(void) updateViewOnRotate:(NSNotification *notification) {
          // update the views
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-27
        • 1970-01-01
        • 2018-03-16
        • 1970-01-01
        相关资源
        最近更新 更多