开发者

Multiple Dynamically drawn Polygon Dragging

I want to put several dynamically drawn polygon in a UIView and make each 开发者_开发百科of such polygon draggable. Should I put each dynamically drawn polygon in a subview and add that to a UIView (Which seems is not possible as one UIView can only display one subview) or should I draw each polygon in different CALayer and cascade the touch event to each layer?


I think your assumptions are wrong. A UIView can certainly contain and display multiple subviews. (That's why subviews is an NSArray -- because there can be many of them.) So yes, you should create a new UIView for each polygon and add them as subviews to your main view.

How do you draw multiple draggable polygons? If you're registered as an iOS developer, you can go to the Apple developer resources and look up the WWDC2011 session videos. In WWDC2001, Session 118, "Making the Most of Multi-Touch on IOS", Ken Kocienda demonstrates an app that does this using gesture recognizers to sense the touches. I don't think the code of the app is available, but he discusses it at length.


It depends on your number of polygons and how dynamic they are. If you have a high number of them, it will be costly to have hundreds of UIViews; in that case you'd be better off with CALayers and tracking the positions manually. If you only have a handful of polygons, then don't complicate your life and go for UIViews.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜