开发者

How can I zoom out an image in a UIScrollView without it being clipped?

I have a UIScrollView that takes up the entire siz开发者_C百科e of the main View Controller's view. In viewDidLoad, I add a UIView with a 600 x 600 image (note this is on an iPhone, not an iPad) to the UIScrollView, and set the UIScrollView's content size to 600 x 600 and the minimum zoom scale to 0.5. However, when I zoom out (with a pinch gesture), the view zooms out, but only the part of the image that was initially visible (320 x 430) appears; the rest of the view is blank.

How can I get the image to fill the view (or, if it's zoomed out far enough, get the entire image to appear) when I zoom out?

code is:

- (void)viewDidLoad 
{ 
[super viewDidLoad];
 UIImage *theImage = [UIImage imageNamed:@"Image600x600.png"];
 UIImageView *vwImage = [[UIImageView alloc] initWithImage:theImage]; 
[theScrollView addSubview:vwImage];
 [theScrollView setContentSize:CGSizeMake(vwImage.bounds.size.width, vwImage.bounds.size.height)]; 
[theScrollView setBounces:NO]; 
[vwImage release]; 
[theScrollView setMaximumZoomScale:5.0]; 
[theScrollView setMinimumZoomScale:0.5];
 }


Without seeing the code it's not clear but perhaps its just clipping the image?

thescrolview.clipsToBounds = NO;


Set the delegate to scrollView and return the imageView to scale/zoom

  • (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView { // Return the view that we want to zoom return vwImage; }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜