在我的UITableViewController中,我设置了一个顶部拖动,但是我使用Count进程来决定何时关闭视图,这样用户不会通过滚动到tableview的顶部意外关闭视图,但是这会创建另一个用户打开视图并决定关闭视图的问题,因此他们必须两次拖动才能退出。有更好的选择吗?
//detect dragging
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
float scrollOffset = scrollView.contentOffset.y;
NSLog(@"%f",scrollOffset);
if (scrollOffset < 0)
{
if(!self.dragCount) self.dragCount = 0;
self.dragCount++;
// then we are at the top
if(self.dragCount == 2) [self dismissViewControllerAnimated:YES completion:Nil];
}
}
最佳答案
如果是表视图,则可以使用scrollViewDidScroll:
,并且可以基于contentOffset.y
选择关闭视图所需的滚动量。
关于ios - 拖动表格 View 顶部时关闭 View 的更好方法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33721771/