开发者

Draggable UIView

开发者 https://www.devze.com 2022-12-20 05:33 出处:网络
I have 4 UIViews inside of a main view controller view. All I need to be able to do is drag the views aroun开发者_StackOverflow社区d the \"screen\". Is UIScrollView the best option for this, or is the

I have 4 UIViews inside of a main view controller view. All I need to be able to do is drag the views aroun开发者_StackOverflow社区d the "screen". Is UIScrollView the best option for this, or is there a simpler way?


Apple's Touches sample application contains code that does just this, so you might want to check it out.


UIScrollView should be used for scrolling, not dragging. And the 4 scroll views won't work if they're overlapped so don't even think of using UIScrollView in your case.

A dedicate UIView subclass that overrides -touches*****:withEvent: is needed. See http://github.com/erica/iphone-3.0-cookbook-/tree/master/C08-Gestures/01-Direct%20Manipulation/ for example.

0

精彩评论

暂无评论...
验证码 换一张
取 消