NT_iOS笔记—iOS图片显示3_界面的手动旋转(UIDeviceOrientation和UIInterfaceOrientation)

文章的图片点击,图片单独显示出来后,转动手机,按照上一篇的方法,图片可以横屏显示出来了。

如果你的图片显示和关闭不需要任何动画效果,或者直接使用系统的动画效果,OK,你的工作已经完成了。

但是如果你不满足简单的动画效果,自己来重新定义动画效果的话,现在问题来了,在横屏是关闭图片,怎么处理动画效果?

最简单的办法就是把界面变成竖屏模式,然后按照竖屏时所定义的动画执行,现在问题又来了,在横屏的时候,怎么重新绘画变成竖屏模式?

解决办法:

-(BOOL)shouldAutorotate
{
    return NO;
}

不支持自动旋转,一切都手动来操作。

通过[UIDevice currentDevice] orientation]来判断当前设备的状态

-(void)ChangeTheOrientation
{
    if (_NTOrientation==[[UIDevice currentDevice] orientation]||[[UIDevice currentDevice] orientation]==UIDeviceOrientationFaceUp||[[UIDevice currentDevice] orientation]==UIDeviceOrientationUnknown||[[UIDevice currentDevice] orientation]==UIDeviceOrientationPortraitUpsideDown||[[UIDevice currentDevice] orientation]==UIDeviceOrientationFaceDown)
    {
        return;
    }
    else
    {
        _NTOrientation=[[UIDevice currentDevice] orientation];
    }
    if (_NTOrientation==UIDeviceOrientationPortrait)
    {
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
        self.view.transform = CGAffineTransformMakeRotation(2*M_PI);
        CGRect frame = [UIScreen mainScreen].applicationFrame;
        self.view.frame=frame;
        _imageView.frame=frame;
        [_imageView changeImageView:_imageView.imageView];
        _imageView.zoomScale = 1;
    }
    else if (_NTOrientation==UIDeviceOrientationLandscapeLeft)
    {
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
        self.view.transform = CGAffineTransformMakeRotation(M_PI/2);
        CGRect frame = [UIScreen mainScreen].applicationFrame;
        self.view.frame=CGRectMake(0, 0, frame.size.height, frame.size.width);
        _imageView.frame=frame;
        [_imageView changeImageView:_imageView.imageView];
        _imageView.zoomScale = 1;
    }
    else if (_NTOrientation==UIDeviceOrientationLandscapeRight)
    {
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
        self.view.transform = CGAffineTransformMakeRotation(-M_PI/2);
        CGRect frame = [UIScreen mainScreen].applicationFrame;
        self.view.frame=CGRectMake(0, 0, frame.size.height, frame.size.width);
        _imageView.frame=frame;
        [_imageView changeImageView:_imageView.imageView];
        _imageView.zoomScale = 1;
    }
}
这样自己手动来控制屏幕的旋转,在关闭图片的时候,手动变成竖屏模式即可



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值