UIScrollView
のスーパークラスUITableView
は、悲惨な生き物になる可能性があります。紙に書かれているように簡単な命題があるように見えるものは、時には難しいものになるほど多くの行動がプログラムされています。それに加えて、このがであるという事実を追加して、それは悪化します。
あなたは、これを達成するためにUITableView
のtableFooterView
プロパティを使用すると判断された場合は、私が使用して制限された(非常に)成功を収めている:
これらはUIScrollViewDelegate
メソッドで、あなたのビューコントローラは、テーブルビューのデリゲートすでにそうです。
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
UIView *tableViewFooter = _tableView.tableFooterView;
CGFloat maxContentOffsetY = tableViewFooter.frame.origin.y - scrollView.frame.size.height;
if (scrollView.contentOffset.y > maxContentOffsetY){
//if (targetPoint.y > maxContentOffsetY){
[scrollView setContentOffset:CGPointMake(0, maxContentOffsetY) animated:YES];
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ // called when scroll view grinds to a halt
// Check offset and correct if we landed below the correct offset
UIView *tableViewFooter = _tableView.tableFooterView;
CGFloat maxContentOffsetY = tableViewFooter.frame.origin.y - scrollView.frame.size.height;
if (scrollView.contentOffset.y > maxContentOffsetY){
[scrollView setContentOffset:CGPointMake(0, maxContentOffsetY) animated:YES];
}
}
単純に、ビューコントローラのビュープロパティにグラデーションを追加することをお勧めします。こうすると、テーブルが画面外にスクロールすると、その背後にグラデーションが表示されます。そうすれば、自由に欲しい行動のほとんどが得られます。