Ios 拉动以添加手势,如Clear中所示

Ios 拉动以添加手势,如Clear中所示,ios,objective-c,uitableview,Ios,Objective C,Uitableview,有人能正确地做到这一点吗 这里有一个关于手势的教程。以下是项目文件: 它远没有最初的Clear应用程序那么流畅: #pragma mark - UIScrollViewDelegate methods - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { // this behaviour starts when a user pulls down while at the top of the table _pull

有人能正确地做到这一点吗

这里有一个关于手势的教程。以下是项目文件:

它远没有最初的Clear应用程序那么流畅:

#pragma mark - UIScrollViewDelegate methods

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
// this behaviour starts when a user pulls down while at the top of the table
_pullDownInProgress = scrollView.contentOffset.y <= 0.0f;

if (_pullDownInProgress)
{
    // add our placeholder
    [_tableView insertSubview:_placeholderCell atIndex:0];
}
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (_pullDownInProgress && _tableView.scrollView.contentOffset.y <= 0.0f)
{
    // maintain the location of the placeholder
    _placeholderCell.frame = CGRectMake(0, - _tableView.scrollView.contentOffset.y - SHC_ROW_HEIGHT,
                                _tableView.frame.size.width, SHC_ROW_HEIGHT);
    _placeholderCell.label.text = -_tableView.scrollView.contentOffset.y > SHC_ROW_HEIGHT ?
                                                @"Release to Add Item" : @"Pull to Add Item";

    _placeholderCell.alpha = MIN(1.0f, - _tableView.scrollView.contentOffset.y / SHC_ROW_HEIGHT);
}
else
{
    _pullDownInProgress = false;
}
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
// check whether the user pulled down far enough
if (_pullDownInProgress && - _tableView.scrollView.contentOffset.y > SHC_ROW_HEIGHT)
{
    [_tableView.datasource itemAdded];
}

_pullDownInProgress = false;
[_placeholderCell removeFromSuperview];
}

@end
#pragma标记-UIScrollViewDelegate方法
-(无效)scrollView将开始刷新:(UIScrollView*)scrollView
{
//当用户在桌子的顶部拉下时,此行为开始
_pullDownInProgress=scrollView.contentOffset.y SHC\u行高度)
{
[\u tableView.datasource itemsadded];
}
_pullDownInProgress=错误;
[_占位符单元格从SuperView中移除];
}
@结束