This should be pretty straight forward, but it appears I need to reach out and ask if others have encountered this...
I've got a project on xcode 6 that's targeting iOS 7+. I'm using a storyboard and autolayout
. I've created a UIViewController
, dropped on a UITableView
, and on that UITableView
I've dropped on 3 different prototype cells, each with varying height. Each proto cell has its own UITableViewCell
class, with UIElement
linked accordingly.
These proto cells are designed in the GUI editor of the storyboard, and each of them have a fixed height. The will never grow in height like this: Using Auto Layout in UITableView for dynamic cell layouts & variable row heights
The problem with all examples I keep finding is that they all use a single prototype cell, and vary the height based on the content (i.e. they're using a UITextView
and sizing the cell height based on how much text in in the view).
Since my proto cells are already designed in the storyboard, and they will never exceed their design height with dynamic content, all I want to do is show them as they are designed, when they are added to the table.
I'm using a switch statement in the cellForRowAtindexPath
to determine which UITableViewCell
class to use based on indexPath.row
.
I created some dummy data in an array and use it to build a table with 3 rows, to see each of the 3 types of cells being rendered in the table.
This all works perfectly on iOS8. On iOS7, however, all three of my cells visually end up piled on top of each other.
For grins, I then implemented a heightForRowAtIndexPath
method, and simply use a switch to determine what indexPath.row
I'm dealing with, and then return back the height of the prototype cell (from the dimensions shown in the storyboard designer). This was supposed to be a simple, hard-coded approach to see if heightForRowAtIndexPath
was needed to solve the issue.
Again, works great on iOS 8, but on iOS7 all 3 cells are piled on top of each other.
I guess a basic question is: since I'm using storyboard-designed prototype cells, that have fixed sizes and constraints on all of the UIComponent
within those proto cells, why doesn't this work on iOS 7?
I'm trying to avoid adding tons of code just make this work on iOS7.