• Pad的界面布局好多时候都要做两套------横屏和竖屏,但在界面切换时,该让哪个布局显示就要判断了,有多种方法,我记录下我用的一种,感觉比较方便:


    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app
        [nc addObserver:self //Add yourself as an observer
               selector:@selector(orientationChanged)
                   name:UIDeviceOrientationDidChangeNotification
                 object:nil];//这个函数用来获取当前设备的方向,
    - (void)orientationChanged
    {
        //UIView *ftView = [self.view viewWithTag:200];
        if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)//判断左右
        {
             //界面的新布局
        }
        if([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait )//我有个方向不支持,如果想都支持那就不要这个if条件就行了
        {
             //界面的新布局
        }
    }

  • 相关阅读:
    golang基础之第一个go程序
    golang基础之工程结构
    golang基础之初识
    Prometheus神器之监控K8s集群
    Kubernetes使用GlusterFS实现数据持久化
    Go使用Makefile构建
    快排的2种分区图解
    密钥交换之DH算法
    go mod使用
    socket常见选项之SO_REUSEADDR,SO_REUSEPORT
  • 原文地址:https://www.cnblogs.com/marysneaker/p/4723571.html
Copyright © 2020-2023  润新知