视图横屏不能完整显示



又是这么一个烂摊子,看我把它给搞定了。


症状:

1.ios 6 底下竖屏进入是ok的,横评进入有这么个情况

2.ios 5地下,是正常的。

简单搜索了一下,http://blog.csdn.net/qq139391025/article/details/8239157

看到这么个现象,有点被唬到了。

求助了一下同事,同事三言两语,我觉得还真有点道理,最基本的怎么就没想到呢,看了一下代码,

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{


    if(ISPHONE){

        self.view.frame = CGRectMake(0, 0, 320, 460);

        //return (interfaceOrientation == UIInterfaceOrientationPortrait);

    }else{

        if (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) {

            self.view.frame = CGRectMake(0, 0, 1024, 748);

        }

        else{

            self.view.frame = CGRectMake(0, 0, 768, 1004);

            //return YES;

        }


    }


   if(ISPHONE){

      return (interfaceOrientation == UIInterfaceOrientationPortrait);

   }else{

       return YES;

   }

 

}


 原来是之前小弟没有按照我的意思写,还真是这个原因。


那就初始化的时候加个判断呗,

viewDidLoad 里面加了这么句话,

UIDeviceOrientation Orientation = [UIDevice currentDevice].orientation;

发现还真是返回unkonw,

一时卡主了,翻看了一下秘籍,482页。“初始启用iphone 时,不会报告方向,只有iphone移动到一个新位置时才会更新方向。秘籍里面也指引用了另外一个方法:用加速度的角度获取当前设备方向”

http://www.cocoachina.com/ask/questions/show/2204/UIDeviceOrientation无法获取当前设备的方向

这里说“

我也遇到同样的问题,用楼主的方法第一次初始化进界面时,无论方向怎样,都是返回0; 但当以后发生转向时,就可以获得当前方向~~~~”


咦,我之前是怎么处理的,参照了一下之前的代码,原来我直接用 self.interfaceOrientation,

期间也学习了一下

UIInterfaceOrientation和UIDeviceOrientation的区别

最后我是这么写的,

if(ISPHONE){

        self.view.frame = CGRectMake(0, 0, 320, 460);

       

    }else{

        

        if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) {

            self.view.frame = CGRectMake(0, 0, 1024, 748);

        }

        if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {

            self.view.frame = CGRectMake(0, 0, 768, 1004);

        }



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值