I have a TableViewController:
As you see I have my own custom bar at the top.
The UITable View is just a static
one, and I add a view at the top of UITableView.
The thing is when I scroll the TableView to top-side it become like bellow image, and I don't want it. is there any easy code that I can limit the scroll for the tableView?
I had the same problem and asked our UX-Designer, how it would be better to do. He said, that both strict solutions (prevent bouncing or allow it as it is) are bad. It's better to allow bouncing but only for some space
My solution was:
Where
64
was that "some space" for me. Code stops tableView at-64
from the top and brings it up with an animation. Good luck!You need to create your view controller object as type
UIViewController
and notUITableViewController
. Then add the custom bar as a subview toself.view
. Create a separateUITableView
and add it below the custom bar. That should make custom bar static and table view scrollable.Update:
In order to make the tableview static you need to set it as
Let me know if this works for you.
since UITableView is a subclass of UIScrollView you can use this UIScrollViewDelegate method to forbid scrolling above the top border
If i understand correctly you have set-up your custom bar as part of your tableview. Put your
custom bar
in a separate view not in the tableview and put your tableview below custom bar when you are setting up your views. You need to create your custom view controller that will have your custom bar and your static table view.Yo will need to set the bounce property of the uitableview to NO
Edit: Note also you can uncheck the bounces from interface builder too
Please check this answer for further details Disable UITableView vertical bounces when scrolling