我想将一张图片全屏显示,但结果如下:
- 全屏:(在此屏幕中,图像处于横向(旋转))
我希望全屏显示图片填满所有屏幕。
我的功能:
-(void)imgToFullScreen{
if (!isFullScreen) {
[UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
//save previous frame
prevFrame = imagen.frame;
//[imagen setFrame:[[UIScreen mainScreen] bounds]];
[imagen setFrame:CGRectMake(0,0,320,415)];
UIImage * portraitImage = [[UIImage alloc] initWithCGImage: imagen.image.CGImage];
UIImage * LandscapeImage = [[UIImage alloc] initWithCGImage: portraitImage.CGImage scale:1.0 orientation: UIImageOrientationRight];
imagen.image = LandscapeImage;
tabbar.hidden = YES;
logo.hidden = YES;
self.navigationController.navigationBarHidden = YES;
}completion:^(BOOL finished){
isFullScreen = true;
}];
return;
}
else{
[UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
[imagen setFrame:prevFrame];
NSData *data = [[NSData alloc] initWithBase64EncodedString:tarjeta.imagen options:0];
imagen.image = [UIImage imageWithData:data];
tabbar.hidden= NO;
logo.hidden = NO;
self.navigationController.navigationBarHidden = NO;
}completion:^(BOOL finished){
isFullScreen = false;
}];
return;
}
}
我该如何解决?
答案 0 :(得分:0)
为什么不用变换简单地旋转它?
imagen.transform = CGAffineTransformMakeRotation(90.0);
将框架设置为keyWindow尺寸(始终为纵向),如果需要则旋转,而内容模式为宽高比填充。
无论如何,我都会将图像放到一个新的模态视图控制器中,其唯一目的是显示初始化的图像。所以你不需要隐藏导航栏,并使用标志等。只需在适当的时候关闭控制器。您的代码会更好地阅读:
-(void)imageViewTouchedUp:(UIImageView*) imageView
{
[[[ImageViewerViewController alloc] initWithImageView:imageView]
presentViewController:self
animated:self.presentAnimated
completion:nil];
}