开发者

Adding an image larger than the iphone view to a UIScrollView

开发者 https://www.devze.com 2023-01-11 18:22 出处:网络
How is an image that is larger than the iphone view size to a UIScrollVi开发者_运维技巧ew? I tried to add the image to the UIImageView, still not connected to the UIScrollView and the image just shru

How is an image that is larger than the iphone view size to a UIScrollVi开发者_运维技巧ew?

I tried to add the image to the UIImageView, still not connected to the UIScrollView and the image just shrunk to fit the UIImageView.

How is this structure set up?

Thanks


You may want to do something like that :

- (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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消