Jamie Forrest
Jamie Forrest

Reputation: 11113

Is there an easy way to reposition views in iOS without manually changing origin/size/center?

I find myself often having to reposition subviews of a view after hiding or showing one of them. The way I'm doing this is by programmatically changing a view frame's origin and/or size, or its center. But is there an easier way I'm missing? Is there a way to do it with Autosizing masks?

Upvotes: 0

Views: 253

Answers (1)

Rob
Rob

Reputation: 437372

I don't think there's any automatic way of doing this. You could probably get clever about how you do it programmatically (e.g. if you used a set of sequential tag identifiers, you could loop through and calculate the height of the previously visible tag to calculate the origin of the next subview; or if there are a group of subviews that are always going to move together, you could put them in a container UIView and thus move a whole bunch of them by just moving their container view; etc. ... it depends upon how they're laid out and which fields might be hidden).

This won't help you for now, but check out WWDC 2012 session 202 for a discussion of a relevant improvement in iOS 6.

Upvotes: 2

Related Questions