iOS: Can I override pinch in/out behavior of UIScrollView?

前端 未结 4 1854
轮回少年
轮回少年 2020-12-19 13:21

I\'m drawing a graph on a UIView, which is contained by a UIScrollView so that the user can scroll horizontally to look around the entire graph.

4条回答
  •  无人及你
    2020-12-19 14:19

    You should instead access the gestureRecognizers (defined in UIView), there are several of them being used by the scroll view,

    figure out which one is the pinch recognizer and call removeGestureRecognizer: on the scroll view, then create your own and have it do the work, add it back with addGestureRecognizer:.

    these are all public API, the recognizers and what order they are in are not (currently), so program defensively when accessing them

    (this is a perfectly valid way to manipulate UIKit views, and Apple won't/shouldn't have issues with it - though they will not guarantee it works in any future release)

提交回复
热议问题