Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,235
126
In my app i call a an image to from a web service to show up in my image view.

after i implemented the zoom for my image view and scrollview, when i get the image it comes out shrunk at the top left hand corner.


how can i get it so it fills up the UIImageView?? and make the zoom and zoom out centered?
 
Providing us with the relevant source code would be most useful in helping you...



ohh sorry forgot about that


Code:
- (void)viewDidLoad
{
    NSLog(@"viewDidLoad");
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    [scrollView setScrollEnabled:YES];
    scrollView.contentSize = productImage.frame.size;
    scrollView.minimumZoomScale = 0.4;
	scrollView.maximumZoomScale = 4.0;
    scrollView.delegate = self;
	[scrollView setZoomScale:scrollView.minimumZoomScale];
    scrollView.frame = CGRectMake (0, 0, 320, 460);
    [scrollView setContentSize:CGSizeMake(320, 600)];
}

-(UIView *) viewForZoomingInScrollView:(UIScrollView *)inScroll 
{
    return productImage;
}
 
Code:
- (void)viewDidLoad
{
    NSLog(@"viewDidLoad");
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    [scrollView setScrollEnabled:YES];
    [b]scrollView.contentSize = productImage.frame.size;[/b]
    scrollView.minimumZoomScale = 0.4;
	scrollView.maximumZoomScale = 4.0;
    scrollView.delegate = self;
	[scrollView setZoomScale:scrollView.minimumZoomScale];
    scrollView.frame = CGRectMake (0, 0, 320, 460);
    [b][scrollView setContentSize:CGSizeMake(320, 600)];[/b]
}

The two lines I bolded strike me as odd... doesn't the second make it so the first effectively isn't there?

What happens if you just get rid of the second? (That's a question, not an answer... I have no idea what will happen, but I hope it's closer to what you want.)

As far as forcing it to remain centered as you zoom and zoom out... you might want to look into adjusting the scroll view's content offset property based on the current zoom to make sure it's centered... I can't think of what the exact equation would be right now...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.