ios - 不同的横向和纵向设计

标签 ios iphone landscape landscape-portrait portrait

您好,我的应用程序采用纵向设计,我想在用户旋转设备时更改此设计。

类似的东西:

肖像:

按钮 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
    }
}

谢谢大家。

最佳答案

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 }

关于ios - 不同的横向和纵向设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31697276/

相关文章:

ios - CAMetalLayer 仅适用于 iOS 13.0

ios - 自动调整自定义 UITableViewCell 的大小

c# - Unity3d 和 iPad 屏幕方向不一致,游戏不受设备旋转影响

iphone - iOS 上的 ImageMagick 圆形扭曲

iphone - 使用个人存储库向 Cydia 提交付费应用程序 - 可能吗?

Android 以当前方向开始布局,之后禁用旋转

css @media 不针对特定设备 iPhone 7 plus

ios - 停止 UIDynamicAnimator Whit View 限制

ios - 字典和表格部分问题 ios

iPhone:获取音频文件的持续时间