I have an image view that is inside of a UIScrollView so that I can pinch & zoom. My image looks fine in portrait mode, but when I go to horizontal orientation the image is not centered.
The UIScrollView is 320x460.
Here is my code:
- (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];
}
And the UIScrollView delegate method
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return imageView;
}
How can I center my image in horizontal orientation?