更改方向时iOS更改UI的最佳方法 [英] iOS best way to change the UI when orientation is changed

查看:76
本文介绍了更改方向时iOS更改UI的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更改方向后,哪种方法是更改​​UI的最佳方法?

Which is the best way to change the UI when orientation is changed?

例如,如果更改方向,则使用两个不同的UIView一张肖像和一幅风景,并显示两者之一,还是使用一个UIView并更改UI控件的大小和位置?

For example, use two different UIView one portrait and a landscape and show one of both if orientation is changed, or use one UIView and change the UI control sizes and positions?

还有其他想法吗?

推荐答案

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    {
        NSLog(@"Change to custom UI for landscape");
    }
    else if (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
        toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        NSLog(@"Change to custom UI for portrait");

    }
}

这篇关于更改方向时iOS更改UI的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆