文章的图片点击,图片单独显示出来后,转动手机,按照上一篇的方法,图片可以横屏显示出来了。
如果你的图片显示和关闭不需要任何动画效果,或者直接使用系统的动画效果,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;
}
}
这样自己手动来控制屏幕的旋转,在关闭图片的时候,手动变成竖屏模式即可