uiscrollviewの中に複数の画像を持つズーム機能を使用したいと思います。スクロールビュー内でscrollviewを試しましたが、問題を整理できませんでした。写真間をスクロールしてズームしたいそれらの写真。uiscrollviewの中で写真を拡大/縮小する
0
A
答えて
0
私はあなたの後ろのものかもしれない簡単なGithubプロジェクトを作成しました。ここで確認してください: https://github.com/twomedia/TMImageZoom
ジェスチャーの状態の変更を処理するクラスを作成することでこれを実現しました。次に、ウインドウ上にUIImageViewを作成し、元の画像ビューに位置/サイズを設定して、ユーザーがimageViewをズームする効果を作り出します。上記のリンクの小さなスニペットは次のとおりです。
-(void) gestureStateChanged:(id)gesture withZoomImageView:(UIImageView*)imageView {
// Insure user is passing correct UIPinchGestureRecognizer class.
if (![gesture isKindOfClass:[UIPinchGestureRecognizer class]]) {
NSLog(@"(TMImageZoom): Must be using a UIPinchGestureRecognizer, currently you're using a: %@",[gesture class]);
return;
}
UIPinchGestureRecognizer *theGesture = gesture;
// Prevent animation issues if currently animating reset.
if (isAnimatingReset) {
return;
}
// Reset zoom if state = UIGestureRecognizerStateEnded
if (theGesture.state == UIGestureRecognizerStateEnded || theGesture.state == UIGestureRecognizerStateCancelled || theGesture.state == UIGestureRecognizerStateFailed) {
[self resetImageZoom];
}
// Ignore other views trying to start zoom if already zooming with another view
if (isHandlingGesture && hostImageView != imageView) {
NSLog(@"(TMImageZoom): 'gestureStateChanged:' ignored since this imageView isnt being tracked");
return;
}
// Start handling gestures if state = UIGestureRecognizerStateBegan and not already handling gestures.
if (!isHandlingGesture && theGesture.state == UIGestureRecognizerStateBegan) {
isHandlingGesture = YES;
// Set Host ImageView
hostImageView = imageView;
imageView.hidden = YES;
// Convert local point to window coordinates
CGPoint point = [imageView convertPoint:imageView.frame.origin toView:nil];
startingRect = CGRectMake(point.x, point.y, imageView.frame.size.width, imageView.frame.size.height);
// Post Notification
[[NSNotificationCenter defaultCenter] postNotificationName:TMImageZoom_Started_Zoom_Notification object:nil];
// Get current window and set starting vars
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
firstCenterPoint = [theGesture locationInView:currentWindow];
// Init zoom ImageView
currentImageView = [[UIImageView alloc] initWithImage:imageView.image];
currentImageView.contentMode = UIViewContentModeScaleAspectFill;
[currentImageView setFrame:startingRect];
[currentWindow addSubview:currentImageView];
}
// Reset if user removes a finger (Since center calculation would cause image to jump to finger as center. Maybe this could be improved later)
if (theGesture.numberOfTouches < 2) {
[self resetImageZoom];
return;
}
// Update scale & center
if (theGesture.state == UIGestureRecognizerStateChanged) {
NSLog(@"gesture.scale = %f", theGesture.scale);
// Calculate new image scale.
CGFloat currentScale = currentImageView.frame.size.width/startingRect.size.width;
CGFloat newScale = currentScale * theGesture.scale;
[currentImageView setFrame:CGRectMake(currentImageView.frame.origin.x, currentImageView.frame.origin.y, startingRect.size.width*newScale, startingRect.size.height*newScale)];
// Calculate new center
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
int centerXDif = firstCenterPoint.x-[theGesture locationInView:currentWindow].x;
int centerYDif = firstCenterPoint.y-[theGesture locationInView:currentWindow].y;
currentImageView.center = CGPointMake((startingRect.origin.x+(startingRect.size.width/2))-centerXDif, (startingRect.origin.y+(startingRect.size.height/2))-centerYDif);
// Reset gesture scale
theGesture.scale = 1;
}
}
+0
を説明ズームアウト –
+0
そして、このジェスチャーを複数のimageviewsにスクロールすると、最後の画像がズームされています。このジェスチャーをscrollview内のすべてのUIImageviewsに追加しても、スクロールビューの最後の画像をズームしています。 –
0
これを試してみてください。
関連する問題
- 1. カメラで写真を撮るときの拡大/縮小オプション
- 2. 拡大写真のピッカービュー
- 3. 拡大/縮小winform
- 4. 写真ステッカーを管理する方法アンドロイドのボタンを削除して拡大縮小しますか?
- 5. サイドバーをReduxで拡大/縮小する
- 6. Androidビットマップイメージの拡大/縮小
- 7. サイトコンテンツの拡大と縮小
- 8. SAPUI5パネル縮小/拡大
- 9. アニメーション拡大/縮小テーブル
- 10. 拡大縮小CSSを使用して自動的に拡大縮小img
- 11. フォトショップでの拡大縮小のホットキー
- 12. イメージビューアンドロイドでのギャラリービューの拡大と縮小
- 13. GMMマウスホイールで拡大/縮小します。
- 14. GTKで画像の拡大/縮小
- 15. Javascriptで複数の画像を拡大/縮小/拡大/縮小する最適な方法は?
- 16. センターアライグなしで写真ビューを拡大して保持する
- 17. UIPinchGestureRecognizer Xamarinで拡大/縮小しない
- 18. CSS:テキストを拡大縮小しないテキストフィールドの拡大
- 19. Xamarin.FormsのFontSizesの拡大縮小ピクセル
- 20. TabBarItemイメージの拡大/縮小方法
- 21. 動的(拡大/縮小)スレッドプールの作成
- 22. アンドロイドで拡大縮小されたレイヤード画像を拡大する
- 23. コンテナ内の画像を中央から拡大縮小できますか?
- 24. 拡大縮小リスト無秩序リスト
- 25. JQuery拡大/縮小関連要素
- 26. Androidのキャンバスで画像を拡大/縮小する
- 27. ピンチズームで個々のオブジェクトを拡大縮小する方法
- 28. フォントを拡大縮小することはできますか?
- 29. NSViewまたは拡大鏡を使用して拡大/縮小する
- 30. ユーザーがウェブページを拡大/縮小するのを止める
あなたの質問にあなたの試したコードを入れて、ユーザーが画像を指を離すと、ユーザーが現在のfinger.Asを持ち上げた後、私はズームアウトして画像を停止したい場合はどのような簡単に – arunjos007