0

I have a xib file with a table view and I want to simple add a UIView with a button inside of it and make that my table view footer view. The height of the UIView (and the button is 50) and setting the section height to match that in IB doesn't seem to help but in the end it seems as if only half of the button is showing and the bottom part of the tableview isn't being shown(i.e. the separator line for the second cell is not visible..see screenshots).

Was wondering if you could help figuring out what the problem is? In the below screenshots you will see the code where I add the view to the footer view in code, a screenshot of interface builder and a screenshot of what is happening on the device. In the code, the UIView with the button inside have an outlet that i am referencing. This UIView has a height of 50 and i set the section height to be 50. Currently I am not implementing any section tableview delegate methods. Don't know that this is needed here.

enter image description here enter image description here enter image description here enter image description here

Leo
  • 24,596
  • 11
  • 71
  • 92
cspam
  • 2,911
  • 2
  • 23
  • 41
  • What is the height of the tableview? Does it scroll when you swipe up? What do you mean by you set the section height? Section footer height? – beyowulf Nov 05 '15 at 03:07
  • the height of the tableview is 128 currently... but obviously the tableview should grow automatically correct? current number of rows is set to 2 but in a more dynamic situation the tableview would need to expand as would be expected correct? Currently I have scrollview disabled. since there are only 2 rows i only want to show those , no need for scrolling. EDIT: if I allow scrolling it looks like that i can scroll up and down and see the rest of the button - but that doesn't explain why i can't just see the button fully without scrolling – cspam Nov 05 '15 at 03:12
  • Also - the separator for the 2nd cell still doesn't show.. perhaps the top part of the button is covering it up. ?? I currently am not using any constraints at all. About the section height - yeah see the 2nd screenshot – cspam Nov 05 '15 at 03:14

1 Answers1

1

If you would like the tableView to take up the entire screen, you must set it's frame to take up the entire screen. A tableView's contentSize will grow automatically, but it's frame will not. There is no provided separator between tableFooterView's and it's preceding row. You don't need to set the height of the sectionFooter; a tableFooterView is distinct from a sectionFooterView as it appears at the bottom of the table and not at the end of a section.

beyowulf
  • 15,101
  • 2
  • 34
  • 40
  • thanks for the feedback. In IB i made the tableview the height of the view and that part seems to work fine. However I am looking for a way for the last cell to have a bottom separator line and to have some spacing between the last cell & the button. So the button would have say a spacing of 20 below the separator line that i add – cspam Nov 05 '15 at 03:48
  • Increase the size of the view you are setting to be the tableFooterView and add a subview of height 1 and make it's background color whatever color you want the separator to be and make it however wide you want it to be and place it toward the top. – beyowulf Nov 05 '15 at 03:54
  • ok thanks. I'm playing around with the separator subview color properties to match that up with the default. Just for those curious that are out there the appropriate colors for the cell separator for iOS 8 and iOS 9 are 200, 199, 204 and a height of 0.5 for it to be pretty exact. You also have to be careful that if you set the height in interface builder to 0.5 at any point it will change it back to 1, so you'll have to set up a height constraint to force it to be 0.5. – cspam Nov 05 '15 at 05:19