1

画像ビューは雑誌のページであるため、UIImageViewを含むスクロールビュー内で単一のビューアプリを作成しています。必要なのは、適切にズームしてスクロールできるようにすることだけです。 (Apple の tapToZoom サンプルのおかげで) タップすると、すべてがうまく機能します。

問題は、実装が少し難しいピンチによるズームを含めたいことです。成功しましたが、ズームはそれほど適切ではありません。スケールをジャンプしているように見えます。また、ズームアウトすると、imageViewはほとんど移動できませんもう見えないってこと?

ここでコントローラーを見ることができます:

https://github.com/HosniD/pinchzoom-iphone/blob/master/scroll/scroll/TestViewController.m

誰かがそれをより良くする方法について考えを持っていますか?

4

3 に答える 3

1

アップルのドキュメントからの回答

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

{

    return self.imageView;

}
- (void)viewDidLoad {

    [super viewDidLoad];

    self.scrollView.minimumZoomScale=0.5;

    self.scrollView.maximumZoomScale=6.0;

    self.scrollView.contentSize=CGSizeMake(1280, 960);

    self.scrollView.delegate=self;

}

私の答えを確認してください

于 2013-12-02T05:49:22.763 に答える
0

ガイダンスとして私のデモ アプリケーションを使用してください: http://rexstjohn.com/facebook-like-ios-photo-modal-gallery-swipe-gestures/

ストーリーボードと自動レイアウトのサポートが含まれています。

于 2013-12-25T05:58:59.960 に答える
0

あなたが望むものは、Apple によって書かれたこのPhotoScroller デモにあります。私はそれを自分で使用しましたが、完全に機能します。

特に ImageScrollView モジュールを確認してください。ズームを処理します。

ズームに関する UIScrollView のヘッダーのコードは次のとおりです。

/*
 the following properties and methods are for zooming. as the user tracks with two fingers, we adjust the offset and the scale of the content. When the gesture ends, you should update the content
 as necessary. Note that the gesture can end and a finger could still be down. While the gesture is in progress, we do not send any tracking calls to the subview.
 the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale: in order for zooming to work and the max/min zoom scale must be different
 note that we are not scaling the actual scroll view but the 'content view' returned by the delegate. the delegate must return a subview, not the scroll view itself, from viewForZoomingInScrollview:
 */

@property(nonatomic) float minimumZoomScale;     // default is 1.0
@property(nonatomic) float maximumZoomScale;     // default is 1.0. must be > minimum zoom scale to enable zooming
于 2012-06-06T12:54:07.550 に答える