zoukankan      html  css  js  c++  java
  • ios 程序窗口适应设备方向改变

     
    //在初始化里注册窗口改变通知,设备窗口改变会发送此通知
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        [[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(change:) name:UIDeviceOrientationDidChangeNotification object:nil];

    }

    returnself;

    }

    -(void) change:(NSNotification*)nt

    {

    CGFloat width = [[UIScreen mainScreen]bounds].size.width * [[UIScreen mainScreen]scale];

    CGFloat height = [[UIScreen mainScreen]bounds].size.height * [[UIScreen mainScreen]scale]; //乘以缩放系数



    UIDeviceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;

    switch (orientation) {

      case UIDeviceOrientationPortrait:

      case UIDeviceOrientationPortraitUpsideDown:

        self.view.frame = CGRectMake(0, 0, width, height);

        break;

      case UIDeviceOrientationLandscapeLeft:

      case UIDeviceOrientationLandscapeRight:

        self.view.frame = CGRectMake(0, 0, height, width);

        break;

      default:

    break;

    }



  • 相关阅读:
    github克隆镜像
    python2安装pip(get-pip.py)和pip更新源
    GitHack使用—create_unverified_context报错
    XCTF:shrine(Flask模块注入)
    开机自启动(C#)
    操作xml(C#)
    隐藏到托盘(C#)
    火狐浏览器下请求两次(C#)
    Nancy学习笔记
    jquery纵向抽屉式导航栏
  • 原文地址:https://www.cnblogs.com/sanjin/p/2272262.html
Copyright © 2011-2022 走看看