我有一张照片,它的大小是1024 * 768,我在图片中添加了一个UIScrollview,问题是当我缩放一切似乎都没问题,直到我转到照片的右边或下边缘我看到有图像下方有一个自由空间,换句话说,缩放是可以的,但是图像没有变焦,而且它的边缘没有连接到uiscrollview的边缘,所以我看到图像下方和右侧的空间,如果我放大了更多空间越来越大,这里是代码:请帮帮我
scrollASync = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
UIImageView *imgv = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
[imgv setImage:[UIImage imageNamed:@"11.jpg"]];
[scrollASync setUserInteractionEnabled:YES];
[scrollASync setMultipleTouchEnabled:YES];
[scrollASync setMinimumZoomScale:1.0];
[scrollASync setMaximumZoomScale:3.0];
[scrollASync setDelegate:self];
[scrollASync setBounces:YES];
[scrollASync setBouncesZoom:YES];
[scrollASync setClipsToBounds:YES];
[scrollASync setContentMode:UIViewContentModeScaleToFill];
[scrollASync addSubview:imgv];
[self.view addSubview:scrollASync];
答案 0 :(得分:2)
尝试使用
imgv.autoresizingMask = UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
希望它有所帮助...
答案 1 :(得分:1)
在Scrollview的委托方法
中- (UIView *)viewForZoomingInScrollView:(UIScrollView *)aScrollView
{
return your imageview;
}