zoukankan      html  css  js  c++  java
  • 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条件就行了
        {
             //界面的新布局
        }
    }

  • 相关阅读:
    原型与原型链
    数据类型与计算
    JavaScript实现版本号比较
    vue依赖
    vue
    面试经验
    第十一节课 课堂总结
    第十一次作业
    第十课课堂总结
    第十次作业
  • 原文地址:https://www.cnblogs.com/marysneaker/p/4723571.html
Copyright © 2011-2022 走看看