iOS 锁屏强制切换屏幕的方向

来源:互联网 发布:氧气听书软件电脑版 编辑:程序博客网 时间:2024/06/05 04:11

    //根据业务需求在屏幕锁定的情况下,设置屏幕的方向,只测了IOS8.1系统


    if([[UIDevice currentDevice]respondsToSelector:@selector(setOrientation:)]) {

        [[UIDevicecurrentDevice]performSelector:@selector(setOrientation:)

                                      withObject:(id)UIInterfaceOrientationLandscapeRight];

    }


    if ([[UIApplication sharedApplication] respondsToSelector:@selector(setStatusBarOrientation:)]) {

        [[UIApplicationsharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeRightanimated:YES];

    }


//旋转屏幕时触发的函数:

//旋转方向发生改变时

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {


}

//视图旋转动画前一半发生之前自动调用

-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {


}

//视图旋转动画后一半发生之前自动调用

-(void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration {

    

}

//视图旋转之前自动调用

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {


}

//视图旋转完成之后自动调用

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {

    

}


//视图旋转动画前一半发生之后自动调用

-(void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {


}


0 0
原创粉丝点击