OGeek|极客世界-中国程序员成长平台

标题: ios - 不同的横向和纵向设计 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 09:22
标题: ios - 不同的横向和纵向设计

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

类似的东西:

肖像:

按钮 1 - 按钮 2

按钮 3 - 按钮 4

风景:

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

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

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

谢谢大家。



Best Answer-推荐答案


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/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4