如何将大于iphone视图大小的图像添加到UIScrollView?
我尝试将图像添加到UIImageView,仍未连接到UIScrollView,图像缩小以适应UIImageView。
这个结构是如何设置的?
由于
答案 0 :(得分:1)
您可能想要做类似的事情:
- (void) resizeScrollContentView
{
CGSize viewSize = _imageView.frame.size;
CGSize scrollSize = _scroll.frame.size;
CGPoint p;
p.x = 0;
p.y = 0;
if(viewSize.width < 320)
{
p.x = 160 - (viewSize.width / 2.0);
}
if(viewSize.height < 460)
{
p.y = 200 - (viewSize.height / 2.0);
}
_imageView.frame = CGRectMake(p.x, p.y, _imageView.frame.size.width, _imageView.frame.size.height);
CGSize endScrollSize;
endScrollSize = _imageView.frame.size;
_scroll.contentSize = endScrollSize;
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
[self resizeScrollContentView];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return _imageView;
}