Auto Layout and Hiding Embedded View Controllers

Discussion in 'iOS Programming' started by isthisonetaken, Dec 7, 2012.

  1. isthisonetaken macrumors regular

    Joined:
    Jun 29, 2006
    #1
    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?
     

    Attached Files:

  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    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".
     
  3. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #3
    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
     

Share This Page