I have the following requirement. When a UITableViewController
's view is displayed, there are a variable number of rows. Underneath the rows, a button should be displayed.
When the number of rows is small, the button should be anchored to the bottom of the view.
When the number of rows is larger, the delete button should be placed immediately after the last row.
In other words:
And not:
My best attempt at this so far has involved setting a tableFooterView
and trying to update its height using the contentSize
of the UITableView
, but I am running into all sorts of problems. I might continue down this path and ask for some help, but first I want to know if anyone has alternative (better) solutions.
The result must play nicely with a double-sized status bar (during a call for example) and I am targeting iOS 6.0. I am not using interface builder.
One possible solution to achieve this effect might have to use two different solutions.
If the amount of rows means that the button will be off the screen then use the footerView like you have been doing.
If the amount of rows means that the button will not be off screen then
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
and update the frame of the button to be offset from the bottom.The offset from the bottom might follow some logic like this
This would mean that the button still moves up and down with the scrolling but you don't have to mess with the footerView height
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With