SwipeTableView icon indicating copy to clipboard operation
SwipeTableView copied to clipboard

用宏定义来使用下拉刷新,请问swipeHeaderView高度变化应该怎么完成

Open SenorSamuel opened this issue 6 years ago • 1 comments

简单的场景: 点击按钮,让swipeHeaderView高度增加,我翻了一下issue,你给出的方案是:#18 但是我使用了这个方案,高度增加了,但是往上滑动的inset不对

复现:你可以直接在demo中,

  • 增加下拉刷新的宏
  • 使用_tapHeader:方法
  • 点击header
  • 往上滚动

SenorSamuel avatar Jan 26 '18 07:01 SenorSamuel

我试了一下,如下代码可以解决

// tap to change header's frame
- (void)tapHeader:(UITapGestureRecognizer *)tap {

    CGFloat changeHeight = 50; // or -50, it will be parallax.
    UIScrollView * currentItem = _swipeTableView.currentItemView;
#if !defined(ST_PULLTOREFRESH_HEADER_HEIGHT)
    CGPoint contentOffset = currentItem.contentOffset;
    UIEdgeInsets inset = currentItem.contentInset;
    inset.top += changeHeight;
    contentOffset.y -= changeHeight;  // if you want the header change height from up, not do this.

    NSMutableDictionary * contentOffsetQuene = [self.swipeTableView valueForKey:@"contentOffsetQuene"];
    [contentOffsetQuene removeAllObjects];

    [UIView animateWithDuration:.35f delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        _tableViewHeader.st_height += changeHeight;
        currentItem.contentInset = inset;
        currentItem.contentOffset = contentOffset;
    } completion:^(BOOL finished) {
        [self.swipeTableView setValue:@(self.tableViewHeader.st_height) forKey:@"headerInset"];
    }];
#else
    UIView * tableHeaderView = ((UITableView *)currentItem).tableHeaderView;
    tableHeaderView.st_height += changeHeight;

    [UIView animateWithDuration:.35f delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        _tableViewHeader.st_height += changeHeight;
        [currentItem setValue:tableHeaderView forKey:@"tableHeaderView"];
    } completion:^(BOOL finished) {
        [self.swipeTableView setValue:@(self.tableViewHeader.st_height) forKey:@"headerInset"];
      
       [self.swipeTableView reloadData];    //刷新一下swipeTableView
    
   }];
#endif

}

SenorSamuel avatar Jan 26 '18 07:01 SenorSamuel