Re-ordering a collection of UIView's based on their CGPoint

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-04-05T15:36:50Z Indexed on 2010/04/15 21:13 UTC
Read the original article Hit count: 218

Hi all,

I have a NSMutableArray that holds a collection of UIViewControllers

Amongst other properties and methods an instance of each of the viewControllers are placed in a parent view

The user will place these objects individually when desired to.

So essentially I use - (void)addSubview:(UIView *)view when a new view is added to the parent view controller.

Because the UI is isometric it's made things a tad more complicated

What I am trying to do is re-order the views based on their co-ordinate position, so items higher up the parent UIView frame is indexed lower then views lower in the parent UIview frame. And items that are on the left side of the view are positioned at a higher index to those on the right

I think the solution may have to do with re-ordering the NSMutableArray but how can I compare the CGpoints? Do I need to compare the x and y separately?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c