• ios6,ios7强制转屏


    在父视图控制器里面写如下代码

    -(void)setViewOrientation:(UIInterfaceOrientation )orientation
    {
        if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
            [[UIDevice currentDevice] performSelector:@selector(setOrientation:)
                                           withObject:(id)orientation];
        }
        [UIViewController attemptRotationToDeviceOrientation];//这句是关键
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    
    -(BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
        return toInterfaceOrientation==UIInterfaceOrientationPortrait;
    }

    在子视图控制器的加入,这里子视图控制器要横屏

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear :YES];
        [self setViewOrientation:UIInterfaceOrientationLandscapeRight];
    }
    //重写下面子类的方法

    - (NSUInteger) supportedInterfaceOrientations{

        returnUIInterfaceOrientationMaskLandscapeRight;

    }

     

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation NS_DEPRECATED_IOS(2_0, 6_0){

        return toInterfaceOrientation == UIInterfaceOrientationLandscapeRight;

    }

     
  • 相关阅读:
    加壳技术
    1002 ( A + B Problem II )
    1000 ( A + B Problem )
    1001 ( Sum Problem )
    背单词Delphi版
    覆盖Form.WndProc来响应消息
    覆盖Dispatch响应消息
    美丽人生论坛看贴工具delphi版
    TWebBrowser组件在DELPHI中POST数据和取得网页源文件
    读淘宝商品描述页源码delphi版
  • 原文地址:https://www.cnblogs.com/xiaobaizhu/p/3435306.html
Copyright © 2020-2023  润新知