Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

isthisonetaken

macrumors regular
Original poster
Jun 29, 2006
123
0
Hey All,

so I'm having a hell of a time with Auto Layout. I have an iPad app and within it, I have a parent view controller which has two embed views on it. I have the children views all setup and working and wanted to have a button which could hide the smaller view and have the larger view expand to take up the extra space. I have that part working, but what I'm having trouble with is that the larger view controller has a table view in it, which normally sits at the bottom of the view. When the embed view grows to take up the extra space (it moves up on the screen), the table view also moves up.

I cannot for the life of me, figure out how to get the table to stay at the bottom of the view. I've been playing with the constraints and none of the changes I make works.

For hiding the views, I get their current frames and then set new frames for when they're hidden/shown and animate those in an animation block. I'm wondering if maybe that has something to do with it? If so though, what's the best way to hide the views?

I made a sample app of what I'm dealing with, to easily show what's up. It's attached as a zip.

Any ideas?
 

Attachments

  • AutoLayoutHELL.zip
    35.4 KB · Views: 71

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,544
6,042
I'm going to take it that you, like me, despise Auto Layout and would much rather not use it.

Just go in your interface file, go to the documents tab (the leftmost tab on the right pane) and uncheck "Use Autolayout".
 

xStep

macrumors 68020
Jan 28, 2003
2,030
143
Less lost in L.A.
I've been looking into Auto Layout this week and so far am not impressed with the IB editing capabilities. Apple out right say in a WWDC 12 video that some things are not currently possible within IB, you have to use code.

For your table view problem you have to edit both the top and bottom vertical constraints. What I found is that for the same relationship, there can be more than one constraint created. The Priority of the constraint goes from 1000, required, down to 1, least wanted I suppose. For the bottom one you'd want a required constraint with an EQUAL qualifier, likely zero from your description.

I played with such a setup for an hour can although I think I figured out the vertical constraint, the horizontal one has me totally puzzled because the same relationship between my table view and it's containing view doesn't appear for the horizontal. :mad: :confused: Things get worse when dealing with a UIView!

Perhaps you can gain some insight by reviewing the following WWDC 2012 videos.

Session 202 - Introduction to Auto Layout for iOS and OS X
Session 219 - Advanced Collection Views and Building Custom Layouts
Session 228 - Best Practices for Mastering Auto Layout
Session 232 - Auto Layout by Example
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.