I'm not sure whether "layout manager" is the correct term, but i'm looking for a way to get UIViews to flow into thier parent view, like left-floated div's would in an HTML page. Is there an easy way to do this, either via the iPhone api's or something external?
A:
I don't know of an API to do this. Core Animation on the Mac has some layout stuff but I think it was not included on the iPhone.
What you describe does not sound extremely difficult though. Open source it? :-)
St3fan
2010-02-04 21:52:43
Yes! I'm generally too sloppy/lazy/selfish for any of my open source intentions to go anywhere. But maybe this'll be different :)
morgancodes
2010-02-04 21:56:55
A:
There is nothing like this really build into the sdk, but it shouldn't be too hard to get the behavior you're after. Just call
NSArray *subs = [parentView subviews];
to get all of the subviews already present. Loop through them like this
CGRect leftMostViewsFrame = nil;
for(UIView *cur in subs){
CGRect where = cur.frame;
//find the left most frame for a given X coord
}
and place your new view next to it
newView.frame = CGRectMake(leftMostViewsFrame.origin.x + leftMostViewsFrame.size.width,
[parentView addSubview:newView];
......
You can write it much more cleanly than that and there is a lot more checking and reasoning you need to do to get all the behavior of float, but that is the basic approach i would take. I don't know if there is a third party lib you could use or not.
Joe Cannatti
2010-02-04 21:57:33