【问题标题】:Different landscape and portrait design不同的横向和纵向设计
【发布时间】:2015-07-29 10:04:16
【问题描述】:

您好,我的应用有一个纵向设计,我想在用户旋转设备时更改此设计。

类似的东西:

肖像:

按钮 1 - 按钮 2

按钮 3 - 按钮 4

风景:

按钮 1 - 按钮 2 - 按钮 3 - 按钮 4

不知道下一个方法是不是最好的:

[[NSNotificationCenter defaultCenter] addObserver:self
                       selector:@selector(didRotate:)
                       name:UIDeviceOrientationDidChangeNotification
                       object:nil];
- (void) didRotate:(NSNotification *)notification{
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (orientation == UIDeviceOrientationLandscapeLeft)    {
        HERE CHANGE THE CONSTRAINS
    }
}

谢谢大家。

【问题讨论】:

    标签: ios iphone landscape landscape-portrait portrait


    【解决方案1】:
    You can do this with using Size Class. i did this... 
    1. First Desigh Screen in wAny - hAny and set all Constrains
    2. For Portrait select wCompact - hRegular and go to Size inspector
    3. In Descendant Constrains there are many Constrains select one by one (double click on that)
    4. you can see two + button. perss it and select wCompact - hRegular. it shownew field set Constrains (Size). do this for all Constrains.
    5. Now for Landscape in storybord select wRegular - hCompact and do this same...
    

    它就像 if - else if 条件... if (Portrait){ this } else if (Landscape) { this }

    【讨论】:

      【解决方案2】:

      为什么不使用尺寸等级?大小类是应用于任何视图或视图控制器的属性,它表示可以在给定的水平或垂直维度上显示的内容量。从 iOS8 开始提供尺寸等级。几乎 90% 的设备都使用 iOS8,但这当然取决于您的要求。

      https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LayoutandAppearance.html

      如果你想支持旧的 iOS 版本,你的方法也不错。

      【讨论】:

      • 谢谢!还有一个问题。在尺寸等级中,横向的 w 和 h 是多少?
      • 这取决于设备。 iPad 和 iPhone 是不同的。当你使用自动布局时,你不应该过多关注这一点。查看本教程raywenderlich.com/83276/beginning-adaptive-layout-tutorial 有一章关于尺寸等级。在开始实施之前对自动布局/大小类有一个很好的了解是很好的。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多