Resolved Layout Constraints

Discussion in 'iOS Programming' started by MickeyT, Apr 7, 2013.

  1. MickeyT, Apr 7, 2013
    Last edited: Apr 7, 2013

    MickeyT macrumors member

    Joined:
    Apr 26, 2010
    Location:
    Newcastle, United Kingdom
    #1
    Does anyone know of any good books or resources (other than the Apple documentation) that explains layout constraints in a way that novices will easily grasp?

    The book I am using was written before these were introduced, and it is driving me up the wall trying to replicate what the book takes for granted or does with seemingly comparative ease under the old approach.

    Turning layout constraints off now (a check box I have only just spotted), doesn't seem to reset everything back to where it would have been if I had not being using layout constraints from the start. I don't want to start again because I have several chapter's worth of work built up from the book I am following.

    In particular, it isn't obvious to me how to create constraints between a view and the superview if they haven't appeared automatically. My understanding is that you select the two things that need a connection with each other and then select the appropriate constraint. However, the superview doesn't seem to be something you can select.

    When I run my app in the simulator as a Retina Display 3.5inch, it works fine, but when run on my iPhone 5, there is a white gap at the bottom of the screen because the top level view isn't resizing properly. Turning layout constraints off doesn't fix this, even though the prevailing autosizing settings seem fine to me.

    This is driving me mad - I'd be grateful for any advice. I'm sure when the next edition of my book is released this will be dealt with, but in the meantime I'm finding it hard going.
     
  2. MickeyT thread starter macrumors member

    Joined:
    Apr 26, 2010
    Location:
    Newcastle, United Kingdom
    #2
    Right, the issue here was related a previously posted thread around having to insert table views programatically to obtain the appropriate background colour because the UIColor that used to do this has been deprecated. I hadn't set the autoresizing mask for the table view, so it wasn't resizing. 3 hours spent just working that out.

    I still despise layout constraints, so any tips on where to find an explanation of how to create and edit them that is written in a more step-by-step manner would be ideal.
     
  3. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #3
    Most of the experienced developers I talk to are not using them.

    I am in that camp as well. We currently target iOS >=5.0, and constraints are not available in iOS 5. I do not want to try to write a hybrid system that handles both methods of form layout.

    iOS books and tutorials tend to lag behind the latest OS extensions from Apple.

    My advice to you is to un-check "Use Autolayout" on every single XIB/Storyboard you create, as soon as you create it, and check 4 or 5 times to make sure you turned the d**n thing off. I think it's ridiculous that Apple made this the default setting on the first release of 6.0, when auto-layout is totally incompatible with earlier OS versions.

    If you are looking to learn about it, Erica Sadun's excellent book "Th Core iOS 6 Developer's Cookbook" has a good chapter on it. I love Erica's writing, and find it a great resource. She provide "recipes" that show how to perform various tasks. You can then incorporate and adapt those recipes to your work. However, I'm not sure how well her style would work for beginners.
     
  4. MickeyT thread starter macrumors member

    Joined:
    Apr 26, 2010
    Location:
    Newcastle, United Kingdom
    #4
    I've been grumpy as hell all day about feeling a bit defeated by it, but that makes me feel a little better. If there's a lack of love for autolayout out there even amongst some of the professionals then that's good enough for me and I think I'll just turn it off and move on. I was only agonising over understanding it because I assumed the rest of the world would be using it and I didn't want to be learning the "old way".

    I can sort of see the benefits, because I suppose it allows you to have much more granular control over the relocation of subviews, but that's not where I'm at right now.

    Thank you for replying.
     
  5. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #5
    I think it depends on your business model. Apple wants us to adopt their new technologies instantly, and pretend that on the day iOS version X is released, that 100% of customers adopt it.

    in the real world, customer adoption takes time, and requiring the latest and greatest OS cuts into your sales.

    I think autolayout looks cool, and should make some things much cleaner and easier. However, I also think they could have given us some guidance on how to create hybrid apps that support both schemes.
     
  6. MattInOz macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #6
    If your looking for good tutorials on new tech in iOS updates, I can recommend
    Ray Wenderlich's ios-6-by-tutorials

    the two largest chapters in the book cover Autolayout one in Interface Builder and the second by code. Worked through both on the weekend. Plus the rest of the book is really good to. I think there is a freebi intro to autolayout as well on the website, which i have to say is an aboslute gold mine of information generally.

    Then again worked through all that then so i could use AutoLayout in a custom TableViewCell only to find a snag that stops it working in that context. I know you mean about finding decent info about AutoLayout on the web. It's almost as bad as NSManagedDocument.
     

Share This Page