0

Does anyone know if you can add a Table View footer in Storyboard?

I was able to add a header, but I can't find a way to add a footer too.

enter image description here

I have a programatic footer right now using viewForFooterInSection:, but I want to put it in Storyboard instead.

EDIT:

I'm able to put a UIView in the Storyboard right here if I drag it on the UITableView.

enter image description here

And if I create an outlet with @IBOutlet weak var footerView: UIView! and set it to self.tableView.tableFooterView = footerView and set self.tableView.sectionFooterHeight = 200 I still can't get anything to show up.

SRMR
  • 3,064
  • 6
  • 31
  • 59
  • Possible duplicate of [How to add a footer to a UITableView in Storyboard](http://stackoverflow.com/questions/9605381/how-to-add-a-footer-to-a-uitableview-in-storyboard) –  Mar 06 '17 at 17:15
  • 1
    https://www.youtube.com/watch?v=VhWjoP3HQcs&ab_channel=vivektakrani –  Mar 06 '17 at 17:15
  • @Sneak Yeah I've checked out those other questions and am still stuck, because I did that for the Header already so I know how to drag a view in there, but for some reason when I do that with the Footer now it doesn't show up on screen? – SRMR Mar 06 '17 at 17:21
  • I am not sure why. You can set the UIView as self.tableView.tableFooterView = yourView. If you have problems, You can simply just implement https://developer.apple.com/reference/uikit/uitableviewdelegate/1614946-tableview?language=objc and return your UIView inside it. Remember to set a correct height for your footer otherwise it wont be visible. https://developer.apple.com/reference/uikit/uitableviewdelegate/1614967-tableview –  Mar 06 '17 at 17:24
  • I just tested it out myself. Simply dragged an UIView in storyboard to a UITableView inside a UIViewController, and made the backgroundColor red for the sake of visiblity, no problems at all. You are doing something wrong and I don't know what it is unfortunately. –  Mar 06 '17 at 17:44
  • Did you drag a header in first, and then try dragging a footer in after? Thanks for checking that though – SRMR Mar 06 '17 at 18:03
  • I had an UITableView ready in my project already with an UIView as header that was dragged on to it already in storyboard too. Didn't even have to do anything in code just drag and drop and it works. Make sure you drop it at the right place and not inside some cell prototype tho! –  Mar 06 '17 at 18:05
  • 1
    Got it. I'm sure you're right and thanks for the help. I'll keep trying to work on it. – SRMR Mar 06 '17 at 18:06

1 Answers1

1

oh, I had a totally same problem and struggle with it almost two hours. I turned out that I had a code which made a tableView unnecessary separator line clear in viewDidLoad(). When I remove it, it worked file.

In short, it can be possible that you have this code in viewDidLoad()

tableView.footerView = UIView.init()