我有一个UIScrollView内部的图像视图,以便我可以捏合和放大放大。我的图像在纵向模式下看起来很好,但是当我进入水平方向时,图像不会居中。
UIScrollView是320x460。
这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame = CGRectMake(0, 0, 320, 460);
self.imageView = [[[AsyncImageView alloc]initWithFrame:frame] autorelease];
[self.imageView loadImageFromURL:self.url];
scrollView.contentSize = CGSizeMake(self.imageView.frame.size.width, self.imageView.frame.size.height);
scrollView.maximumZoomScale = 4.0;
scrollView.minimumZoomScale = 0.75;
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
[scrollView addSubview:self.imageView];
}
和UIScrollView委托方法
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return imageView;
}
如何将图像置于水平方向?
答案 0 :(得分:0)
尝试自动调整滚动视图:
scrollview.autoresizingMask = ( UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleWidth );