0

I've been following 6 or 7 tutorials already about table view cells, and they have been behaving seriously wrong (for example: as I click a row, the imageview resizes and covers the whole cell).

Since I'm new to iOS I have only read about things like constraints and auto-layout, and understand them theoretically. Given the fact that I have not set up anything related to auto layout or constraint, my storyboard prototype cell have only drag-n-dropped labels and imageviews and the Use autolayout checkbox is checked.

Up to this point, I have the theory that since use autolayout is checked, and no constraint is set up whatsoever, that is the cause of the strange behavior.

Also, in the Size inspector each view (imageview, label, other label) has different autosizing definition.

My question would be what is the relationship between autolayout, constraint, and autosizing

Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206
  • `Autolayout` is a system that lets you lay out your app’s user interface by creating a mathematical description of the relationships between the elements. You define these relationships in terms of `constraints`. This is from the first two sentences of the documentation:https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html . `Autosizing` masks (also called springs and structs) is a previous technology that is simpler than autolayout but neither as flexible nor as comprehensive. – Robotic Cat Aug 08 '14 at 16:36
  • If you are new to Autolayout and / or iOS then I suggest you follow a tutorial on Autolayout explicitly as it will same you time and effort (e.g.:http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1) or watch the appropriate WWDC 2012 / WWDC 2013/ WWDC 2014 videos. – Robotic Cat Aug 08 '14 at 16:39
  • does that means autosize is not to be used with autolayout? also, does it also me if use autolayout checkebox is enabled, I **MUST** set constraints, otherwise it will screw up everything? – Christopher Francisco Aug 08 '14 at 16:52
  • You should go with one or the other. I strongly recommend `Autolayout` as this is the future of OS X and iOS application development. If you don't set any constraints the default will be for nothing to happen but once you start setting constraints you should set them all in your cell. As an aside, from iOS 8, using constraints in your tableview cells will allow dynamic cell sizing (you no longer have to return a `tableView:heightForRowAtIndexPath:` value) – Robotic Cat Aug 08 '14 at 17:13
  • I understand. I removed all autosizing red arrows for every cell subview (image and labels). If no constraint is set, the cell is rendered fine, but as soon as I click or scroll, the **image view** resizes taking the whole cell (so nothing else is visible). Is this because no constraint is set, or is there something else wrong?. Using iOS 7.1 simulator btw – Christopher Francisco Aug 08 '14 at 18:36
  • Sounds like something else is wrong. You should provide a screenshot of the cell in Xcode (with the side panel expanded) to confirm there are no constraints. Maybe also a screenshot of the actual problem. – Robotic Cat Aug 08 '14 at 18:48
  • Since this issue is no longer related to the question, here's the new question: http://stackoverflow.com/questions/25210810/tableviewcell-with-autolayout-constraint-issue – Christopher Francisco Aug 08 '14 at 19:22

0 Answers0