UIScrollView
の中にUIImageView
があるので、ズームが可能ですが、ズームは機能しますが、UIImageView
を中央に保持せずに終わり、黒いスペースを残します上に。UIScrollViewのUIImageViewが中心にズームしない
これは私が持っているものです。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
scroller.bouncesZoom = YES;
scroller.clipsToBounds = YES;
float scale = image.size.width/320;
UIImage *scaled = [UIImage imageWithCGImage:[image CGImage] scale:scale orientation:UIImageOrientationUp];
imageView = [[UIImageView alloc] initWithImage:scaled];
imageView.userInteractionEnabled = YES;
[imageView setCenter:CGPointMake(160,240)];
[scroller addSubview:imageView];
scroller.contentSize = [imageView frame].size;
scroller.maximumZoomScale = 4.0;
scroller.minimumZoomScale = 1.0;
scroller.zoomScale = 1.0;
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return imageView;
}
任意の提案ですか?以下は
去年のWWDCでスクロールビューのデザインに関する話がありました。それを見て、それは本当に私の多くを助けました:) – Julian