-2
我有和HERE一样的问题..请帮助!旋转UIImageView后滚动和缩放的问题
我有一个UIViewController是 支持滚动和 的UIImageView的缩放。它效果很好。
我试图添加对方向变化 的支持。由于各种原因,I 需要通过旋转UIImageView而不是UIImageController来执行此操作。
我有图像旋转的工作,但 如果捏缩放当图像 旋转的用户,图像的大小和 位置去疯狂(例如, 跳转到侧面的图像,获取太小, 似乎不知道滚动视图的范围 在哪里,等等)。
第h文件的核心内容:
@interface ImageViewController : UIViewController <UIScrollViewDelegate>
{
IBOutlet UIScrollView *scrollView;
IBOutlet UIImageView *imageView;
}
@property (nonatomic, assign) UIScrollView *scrollView;
@property (nonatomic, assign) UIImageView *imageView;
@end
支持用于变焦:
-(UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return imageView;
}
支持滚动(组 图像被加载之后) :
[scrollView setContentSize: CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height)];
支持时 方向改变旋转图像:
-(void)orientationChanged:(NSNotification *)note
{
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
CGFloat angle = 0;
switch (orientation)
{
case UIDeviceOrientationLandscapeLeft:
angle = M_PI/2.0f;
break;
case UIDeviceOrientationLandscapeRight:
angle = -M_PI/2.0f;
break;
case UIDeviceOrientationPortraitUpsideDown:
angle = M_PI;
break;
default:
break;
}
self.imageView.transform = CGAffineTransformMakeRotation(angle);
}
我怀疑的问题是, 滚动视图是困惑,因为 尺寸图象具有由于 的轮换而改变,但我对 无能为力。有任何想法吗? FWIW,如果我更改 方向,但在缩放之前将 更改为“垂直”,则缩放功能不起作用。
试着在这里详细说明以获得答案。我编辑了您的原始帖子。从链接复制粘贴。 – 2011-05-12 13:31:00