如何在iPhone中的UIPinchGesture中设置放大后uiscrollview的内容大小

发布于 2024-12-15 14:13:49 字数 658 浏览 1 评论 0原文

我必须在 iphone 中实现 UIPinchGesture ,我的代码如下:

    - (void)handlePinch:(UIPinchGestureRecognizer*)recognizer
    {
      if ( [recognizer state] == UIGestureRecognizerStateBegan || 
            [recognizer state] == UIGestureRecognizerStateChanged ) 
     {
     NSLog(@"=======Scale Applied===========");
     if ( [recognizer scale]<1.0f ) 
     {
         [recognizer setScale:1.0f];
     }
    CGAffineTransform transform = CGAffineTransformMakeScale([recognizer scale],     [recognizer scale]);
    self.view.transform = transform;

}

这段代码对于放大和缩小工作正常,但是当我放大时,我无法 滚动视图,以便我可以阅读视图上的文本。

谢谢。

I have to implement UIPinchGesture in iphone for that my code as follows:

    - (void)handlePinch:(UIPinchGestureRecognizer*)recognizer
    {
      if ( [recognizer state] == UIGestureRecognizerStateBegan || 
            [recognizer state] == UIGestureRecognizerStateChanged ) 
     {
     NSLog(@"=======Scale Applied===========");
     if ( [recognizer scale]<1.0f ) 
     {
         [recognizer setScale:1.0f];
     }
    CGAffineTransform transform = CGAffineTransformMakeScale([recognizer scale],     [recognizer scale]);
    self.view.transform = transform;

}

This code is working fine for zooming in and zooming out but when i zoom in i am not able to
scroll the view so that i can read the text on the view.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以笙箫默 2024-12-22 14:13:49

您必须使用 UIScrollView 而不是 UIView。完成此操作后,您必须调整滚动视图的内容大小。

[myScrollView setContentSize:CGSizeMake(width, height)]

如果内容大于屏幕,则滚动视图会自动滚动。

希望有帮助。

You have to use a UIScrollView instead your UIView. Once you have done this, you have to resize the content size of your scroll view.

[myScrollView setContentSize:CGSizeMake(width, height)]

if the content is bigger than the screen the scrollview is automatically scrollable.

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文