Reputation: 4815
I have one UITableView
and i want to set bouncing only one side top side.
but i could not solve this problem . see this video link and give me solution for that . any suggestion is appreciate and accepted.
Here https://www.dropbox.com/s/qztsfkqoxuy4aaj/question.mov?dl=0
Here is my tableview info.
Upvotes: 1
Views: 745
Reputation: 3446
Use the method scrollViewDidScroll
to check the content offset of the tableview's scrollview. check if the user is trying to scroll beyond the bottom bounds of the table view. if so, scroll back to end of tableview. this will not limit bottom bounce but will scroll back so quickly that user will not notice bottom bounces.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height) {
[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, scrollView.contentSize.height - scrollView.frame.size.height)];
}
}
///UPDATE-- If Tableview's content size will be less than its frame, above code may not work. you can use following in that case:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if(scrollView.contentSize.height > scrollView.frame.size.height)
{
if (scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height) {
[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, scrollView.contentSize.height - scrollView.frame.size.height)];
}
}
else if (scrollView.contentOffset.y >= 0)
{
[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, 0)];
}
}
Upvotes: 7