zoukankan      html  css  js  c++  java
  • 获取屏幕旋转的通知

    在viewcontroller里加上这句:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:)
    name:UIDeviceOrientationDidChangeNotification object:nil];//屏幕旋转的通知

    在通知的方法里加上这句:

    -(void)statusBarOrientationChange:(NSNotification*)no{
    
        NSDictionary* ntfDict = [no userInfo];
        self.collectionView.frame = CGRectMake(0, 0, DF_WIDTH, DF_HEIGHT);//如果要重置view的大小的话,一定要加上这句
        UIDeviceOrientation interfaceOrientation = [UIDevice currentDevice].orientation;
            if (interfaceOrientation == UIDeviceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown) {
                //翻转为竖屏时
                count = 3;
                [self.collectionView reloadData];
        
            }else if (interfaceOrientation==UIDeviceOrientationLandscapeLeft || interfaceOrientation == UIDeviceOrientationLandscapeRight) {
                //翻转为横屏时
                count = 5;
                [self.collectionView reloadData];
            }
    }

    更全总结: [iOS]关于iOS中界面视图横屏/竖屏切换的问题总结:http://blog.csdn.net/lqq200912408/article/details/51088987

  • 相关阅读:
    SpringMVC 工作流程
    zookeeper
    Zookeeper
    HashMap
    Shiro learning
    Shiro learning
    Shiro learning
    Easy Poi入门
    Enum枚举学习- java5之前和之后的写法
    linux命令行todo列表管理工具Taskwarrior介绍
  • 原文地址:https://www.cnblogs.com/lucky-star-star/p/5787284.html
Copyright © 2011-2022 走看看