イメージビューをダブルタップした後、スクロールビューのコンテンツサイズと同じイメージサイズを設定したい。
アプリとそのktphotoviewオブジェクト(uiscrollviewオブジェクト)でktphotobrowserを使用しています
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if ([touch view] == self) {
if ([touch tapCount] == 2) {
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(toggleChromeDisplay) object:nil];
//[self zoomToRect:[self zoomRectForScale:[self maximumZoomScale] withCenter:[touch locationInView:self]] animated:YES];
//[self setContentSize:imageView_.bounds.size];
//[self zoomToLocation:[touch locationInView:self]];
CGPoint pointInView = [touch locationInView:self];
// Get a zoom scale that's zoomed in slightly, capped at the maximum zoom scale specified by the scroll view
CGFloat newZoomScale = self.zoomScale * 2.0;
NSLog(@"zoomscale %f",newZoomScale);
newZoomScale = MIN(newZoomScale, self.maximumZoomScale);
// Figure out the rect we want to zoom to, then zoom to it
CGSize scrollViewSize = self.bounds.size;
CGFloat w = scrollViewSize.width / newZoomScale;
CGFloat h = scrollViewSize.height / newZoomScale;
CGFloat x = pointInView.x - (w / 2.0f);
CGFloat y = pointInView.y - (h / 2.0f);
CGRect rectToZoomTo = CGRectMake(x, y, w, h);
[self zoomToRect:rectToZoomTo animated:YES];
}
}
}
scrollview の maximumzoomscale は 2.0 に設定されています
私の画像の元のサイズは 1280x853 です。ダブルタップすると、myimageview のバインドされたダイの高さは 640 になり、スクロールビューのコンテンツ サイズの高さは 960 (uiscreen.size.height * maximumzoomscale) になります。
しかし、私が望むのは、画像ビューの高さとコンテンツサイズの高さの両方を同じにする必要があるため、ユーザーは画像の外にスクロールできません
このビューでこれらの計算と設定をどこでどのように行うことができますか?高さと幅の両方をどこで設定できますか?
ありがとう