简体   繁体   English

UIScrollView,滑动,缩放

[英]UIScrollView, sliding, zooming

I have an app which has a uiscrollview, which in turn has two uiimageviews. 我有一个具有uiscrollview的应用程序,该应用程序又具有两个uiimageviews。 The scrollview works fine in sliding between both imageviews, by making the content size twice the width. 通过将内容大小设置为宽度的两倍,scrollview在两个图像视图之间滑动时效果很好。 like so 像这样

   [self.scrollView setContentSize:CGSizeMake(self.scrollView.frame.size.width * 2, self.scrollView.frame.size.height)];

Now the client wants the user to be able to zoom into any image in those two images. 现在,客户希望用户能够放大这两个图像中的任何图像。 He does not want another modal view with the selected picture zoomed in, but rather on the same uiscrollview he wants this to happen. 他不希望将所选图片放大的其他模式视图,而是希望在同一uiscrollview上进行。 Is this doable? 这可行吗? or a good Idea? 还是一个好主意?

The problem I am having is that when I implement the zooming logic ( implementing the delegate 我遇到的问题是,当我实现缩放逻辑(实现委托

  UIScrollViewDelegate

the moment I set the value of 当我设定

 self.scrollView.zoomScale

I end up calling this method 我最终调用此方法

 - (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView {
   return [self getCurrentVisibleImage];
 }

And with that happening, I end up with the UIscrollview that after zooming back to the normal size of the image, the scrollview simply doesn't slide left or right? 发生这种情况时,我最终得到UIscrollview,该UIscrollview放大到图像的正常大小后,scrollview根本不会向左或向右滑动?

Any help is appreciated. 任何帮助表示赞赏。

Answer was simple, I was manipulating contentsize and not setting it properly. 答案很简单,我正在操纵contentsize并没有正确设置它。 that fixed it. 修复它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM