How to set automatic height of static cell in UITableViewController?

bpiec

I am using IB and storyboard and I defined UITableViewController. There I defined three static cells. The first two should have a given height but the last one should automatically fill the remaining space (anchor to the bottom of the view). How can I achieve this? I can use autolayout for the controls inside the cell but it is greyed out for the cell itself.

The best solution would be to do this from IB but programmatic solutions are also welcomed.

EDIT:

This is how it looks in my storyboard (colors are for visualizing separate controls, each control has required constraints): Storyboard view controller

And after launching: Simulator view Note that the text view ends below the bottom of the screen.

I forgot to mention that I target iOS 7.0+.

Christos Chadjikyriacou

Ok try this

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat{

    if indexPath.row == 0 { 
        return firstRowHeight
    }
    else if indexPath.row == 1 { 
        return secondRowHeight 
    }
    else { 
        return tableView.frame.size.height - firstRowHeight - secondRowHeight 
    }
}

The only thing that may be a problem is that this method is going to run before the view sets the tableView height

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Css accordion menu, how to set height to automatic?

From Dev

Set default selected cell in UITableViewController

From Dev

How to change cell height dynamically in UITableView static cell

From Dev

Dynamic prototype cell height size of UITableViewController on storyboard

From Dev

How to set table border less then cell height

From Dev

when set background image in div at time i have to give static height of div otherwise it not take automatic height

From Dev

How to set height of table cell "display: table-cell"

From Dev

How to add cell dynamically in uitableviewcontroller?

From Dev

iOS 8.3 breaks automatic cell height

From Dev

PHPExcel How to apply styles and set cell width and cell height to cell generated dynamically

From Dev

angularjs ng-grid how to set row or cell height

From Dev

How to set minimum height of row in prawn Table cell

From Dev

Automatic tableview cell height for only one type of prototype cell

From Dev

UICollectionview set cell height based on image height

From Dev

Swift: How to set dynamic cell height in TableViewController which contains more than one cell

From Dev

How to access to a static cell

From Dev

How to set automatic width?

From Dev

How to set an automatic BufferSize?

From Dev

Configuring TableView with automatic cell height results in no cells displayed

From Dev

How is table cell height calculated?

From Dev

Unable to set the height of a prototype cell as a constraint in storyboard

From Dev

Set row height of a UITableView according to the cell in that row

From Dev

Set cell height in PDF table created with itextsharp

From Dev

Set height of cell equal to the label content

From Dev

set Dynamic width and height of collection view cell

From Dev

Set height of a specific cell in my UITableView

From Dev

how to implement UITableViewController with multiple prototype cell programmatically in swift

From Dev

How do I delete a UILocalNotification within a UITableViewController cell?

From Dev

Set height of UITableView which contain dynamic Cell Height

Related Related

  1. 1

    Css accordion menu, how to set height to automatic?

  2. 2

    Set default selected cell in UITableViewController

  3. 3

    How to change cell height dynamically in UITableView static cell

  4. 4

    Dynamic prototype cell height size of UITableViewController on storyboard

  5. 5

    How to set table border less then cell height

  6. 6

    when set background image in div at time i have to give static height of div otherwise it not take automatic height

  7. 7

    How to set height of table cell "display: table-cell"

  8. 8

    How to add cell dynamically in uitableviewcontroller?

  9. 9

    iOS 8.3 breaks automatic cell height

  10. 10

    PHPExcel How to apply styles and set cell width and cell height to cell generated dynamically

  11. 11

    angularjs ng-grid how to set row or cell height

  12. 12

    How to set minimum height of row in prawn Table cell

  13. 13

    Automatic tableview cell height for only one type of prototype cell

  14. 14

    UICollectionview set cell height based on image height

  15. 15

    Swift: How to set dynamic cell height in TableViewController which contains more than one cell

  16. 16

    How to access to a static cell

  17. 17

    How to set automatic width?

  18. 18

    How to set an automatic BufferSize?

  19. 19

    Configuring TableView with automatic cell height results in no cells displayed

  20. 20

    How is table cell height calculated?

  21. 21

    Unable to set the height of a prototype cell as a constraint in storyboard

  22. 22

    Set row height of a UITableView according to the cell in that row

  23. 23

    Set cell height in PDF table created with itextsharp

  24. 24

    Set height of cell equal to the label content

  25. 25

    set Dynamic width and height of collection view cell

  26. 26

    Set height of a specific cell in my UITableView

  27. 27

    how to implement UITableViewController with multiple prototype cell programmatically in swift

  28. 28

    How do I delete a UILocalNotification within a UITableViewController cell?

  29. 29

    Set height of UITableView which contain dynamic Cell Height

HotTag

Archive