重温自动旋转和自动调整大小

来源:互联网 发布:贪心算法举例 编辑:程序博客网 时间:2024/05/03 00:06

问题描述:

原来是这样子写的

    if (interfaceOrientation == UIInterfaceOrientationPortrait ||interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {

        NSLog(@"myPortrait before:%@",myPortrait);

        DerictionV = 1;

        //        logonView.view  = logonView.portrait;

        self.view = myPortrait;

        scrollView_P.contentSize = CGSizeMake(scrollView_P.bounds.size.width, scrollView_P.bounds.size.height+200);

        NSLog(@"myPortrait after:%@",myPortrait);

    }

    else{

        NSLog(@"myLandscape before:%@",myLandscape);

        DerictionV = 0;

        //        logonView.view  = logonView.landscape;

        self.view = myLandscape;

        scrollView_L.contentSize = CGSizeMake(scrollView_L.bounds.size.width, scrollView_L.bounds.size.height+200);

        NSLog(@"myLandscape after:%@",myLandscape);

    }

记录了一下日志:


2012-12-03 11:18:34.786 CPL_OA[2606:f803] myLandscape after:<UIView: 0xbaf7120; frame = (20 0; 748 1024); autoresize = W+H; layer = <CALayer: 0xbaf7150>>
2012-12-03 11:18:34.786 CPL_OA[2606:f803] DerictionV:0
2012-12-03 11:18:35.658 CPL_OA[2606:f803] myPortrait after:<UIView: 0xbafa3b0; frame = (-118 118; 1004 768); autoresize = W+H; layer = <CALayer: 0xbafa3e0>>
2012-12-03 11:18:35.659 CPL_OA[2606:f803] DerictionV:1
2012-12-03 11:18:36.281 CPL_OA[2606:f803] myLandscape after:<UIView: 0xbaf7120; frame = (20 0; 748 1024); autoresize = W+H; layer = <CALayer: 0xbaf7150>>
2012-12-03 11:18:36.281 CPL_OA[2606:f803] DerictionV:0
2012-12-03 11:18:36.862 CPL_OA[2606:f803] myPortrait after:<UIView: 0xbafa3b0; frame = (-118 118; 1004 768); autoresize = W+H; layer = <CALayer: 0xbafa3e0>>
2012-12-03 11:18:36.863 CPL_OA[2606:f803] DerictionV:1
2012-12-03 11:18:37.681 CPL_OA[2606:f803] myLandscape after:<UIView: 0xbaf7120; frame = (20 0; 748 1024); autoresize = W+H; layer = <CALayer: 0xbaf7150>>
2012-12-03 11:18:37.682 CPL_OA[2606:f803] DerictionV:0
2012-12-03 11:18:38.296 CPL_OA[2606:f803] myPortrait after:<UIView: 0xbafa3b0; frame = (-118 118; 1004 768); autoresize = W+H; layer = <CALayer: 0xbafa3e0>>
2012-12-03 11:18:38.296 CPL_OA[2606:f803] DerictionV:1
2012-12-03 11:18:38.940 CPL_OA[2606:f803] myLandscape after:<UIView: 0xbaf7120; frame = (20 0; 748 1024); autoresize = W+H; layer = <CALayer: 0xbaf7150>>
2012-12-03 11:18:38.941 CPL_OA[2606:f803] DerictionV:0
2012-12-03 11:18:39.537 CPL_OA[2606:f803] myPortrait after:<UIView: 0xbafa3b0; frame = (-118 118; 1004 768); autoresize = W+H; layer = <CALayer: 0xbafa3e0>>
2012-12-03 11:18:39.538 CPL_OA[2606:f803] DerictionV:1
2012-12-03 11:18:40.126 CPL_OA[2606:f803] myLandscape after:<UIView: 0xbaf7120; frame = (20 0; 748 1024); autoresize = W+H; layer = <CALayer: 0xbaf7150>>
2012-12-03 11:18:40.127 CPL_OA[2606:f803] DerictionV:0
2012-12-03 11:18:40.595 CPL_OA[2606:f803] myPortrait after:<UIView: 0xbafa3b0; frame = (-118 118; 1004 768); autoresize = W+H; layer = <CALayer: 0xbafa3e0>>
2012-12-03 11:18:40.596 CPL_OA[2606:f803] DerictionV:1
2012-12-03 11:18:41.070 CPL_OA[2606:f803] myLandscape after:<UIView: 0xbaf7120; frame = (20 0; 748 1024); autoresize = W+H; layer = <CALayer: 0xbaf7150>>
2012-12-03 11:18:41.071 CPL_OA[2606:f803] DerictionV:0
2012-12-03 11:18:41.530 CPL_OA[2606:f803] myPortrait after:<UIView: 0xbafa3b0; frame = (-118 118; 1004 768); autoresize = W+H; layer = <CALayer: 0xbafa3e0>>
2012-12-03 11:18:41.531 CPL_OA[2606:f803] DerictionV:1


碰到个相关的问题,查阅了相关view的只是,无解,于是乎捡起旧书本,记录于此。

内部正方形,实线,自由改变宽度;虚线,竟可能原值。

四周的四个红色“I”。如果“I”是虚线,那么距离就是灵活可变的;如果“I”是红色实线,则间距的值应尽可能保持不变。


内部和外部是相反的,注意到没。略微有点忘了。平时都是看动画的。(这段跟整个问题无关,看书的时候看到,又有点忘了,顺便记录一下)


抄了书上的代码,就ok了。

    if (toInterfaceOrientation==UIInterfaceOrientationPortrait) {

        DerictionV = 1;

        self.view=self.myPortrait;

        self.view.transform=CGAffineTransformIdentity;

        self.view.transform=CGAffineTransformMakeRotation(degreesToRadians(0));

        self.view.bounds=CGRectMake(0.0, 0.0, 768.0, 1024.0);

        

    }

    if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft) {

        DerictionV = 0;

        self.view=self.myLandscape;

        self.view.transform=CGAffineTransformMakeRotation(degreesToRadians(0));

        self.view.transform=CGAffineTransformMakeRotation(degreesToRadians(-90));

        self.view.bounds=CGRectMake(0.0, 0.0, 1024.0, 768.0);

    }

    if (toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) {

        DerictionV = 1;

        self.view=self.myPortrait;

        self.view.transform=CGAffineTransformMakeRotation(degreesToRadians(180));

        self.view.bounds=CGRectMake(0.0, 0.0, 768.0, 1024.0);

    }

    if (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight) {

        DerictionV = 0;

        self.view=self.myLandscape;

        self.view.transform=CGAffineTransformMakeRotation(degreesToRadians(90));

        self.view.bounds=CGRectMake(0.0, 0.0, 1024.0, 768.0);

    }


原创粉丝点击