1

我正在制作一个包含 UIImageView 的滚动视图中的单视图应用程序,因为图像视图是杂志页面,我需要做的就是使其能够正确缩放并滚动,所以我设置了缩放点击(感谢苹果的 tapToZoom 示例),一切正常。

问题是我想包括通过捏缩放这有点难以实现,我成功了,但缩放不是那么正确,它似乎是跳跃的比例,当我缩小时,imageView 可以去这么少它不再可见了?

您可以在这里查看控制器:

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

有谁知道如何让它变得更好?

4

3 回答 3

1

Answer from apple documentation

- (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;

}

Check my answer

于 2013-12-02T05:49:22.763 回答
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 回答
0

使用我的演示应用程序获得指导:http ://rexstjohn.com/facebook-like-ios-photo-modal-gallery-swipe-gestures/ 。

包括对故事板和自动布局的支持。

于 2013-12-25T05:58:59.960 回答