开发者

Reorder Subviews

What is the best approach to re-ording a series of subviews contained within a large root view such that they are neatly aligned and sorted based on the subviews relative position in the root view. Like the way Finder's clean up command works. I've tired sorting my subviews by their upper left corner's X then Y coordinates but that doesn't yield optimal results since a subview to the right of another subview but closer to the top is moved to first position. There can me multiple rows and columns in the root view too.

I give the user freedom to move the subviews around by touching and dragging, this opti开发者_运维知识库on is to neaten them up so they line up in nice neat rows and columns. The subviews are of different size too (FYI).

Any insight would be greatly appreciated.

Thanks in advance,

Rob


I suggest you calculate a possible grid based on the sizes of the super view and the size of the subviews. Simple math will tell you what the boundaries are for every cell in your grid, so whenever one of the subviews isn't exactly inside those grid cells, you can let them animate/move to the correct origin in your "grid".

Hope this helps,

Bryan

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜