Giter VIP home page Giter VIP logo

Comments (14)

liangdrime avatar liangdrime commented on May 22, 2024

很抱歉,我不是很清楚你说的垂直方向bounce是什么意思。如果说每个item的话,默认都是有的。你能具体描述一下你的问题吗?

from swipetableview.

CoderJackie avatar CoderJackie commented on May 22, 2024

我设置了每个item的bounce,但是只有上拉的时候有效果,下拉的时候,顶部还是可以继续拉

from swipetableview.

CoderJackie avatar CoderJackie commented on May 22, 2024

所以我考虑应该是STHeader中pan手势,在改变header的frame时作判断,
` case UIGestureRecognizerStateChanged:
{
self.tracking = NO;
self.dragging = YES;
CGRect frame = self.frame;
CGPoint translation = [panGestureRecognizer translationInView:self.superview];
CGFloat newFrameOrginY = frame.origin.y + translation.y;
CGPoint minFrameOrgin = [self minFrameOrgin];
CGPoint maxFrameOrgin = [self maxFrameOrgin];

        CGFloat minFrameOrginY = minFrameOrgin.y;
        CGFloat maxFrameOrginY = maxFrameOrgin.y;
        CGFloat constrainedOrignY = fmax(minFrameOrginY, fmin(newFrameOrginY, maxFrameOrginY));
        CGFloat rubberBandedRate  = rubberBandRate(newFrameOrginY - constrainedOrignY);

        frame.origin  = CGPointMake(frame.origin.x, frame.origin.y + translation.y * rubberBandedRate);
        self.newFrame = frame;

        [panGestureRecognizer setTranslation:CGPointMake(translation.x, 0) inView:self.superview];
    }
        break; `

但是不知道UIGestureRecognizerStateChanged里面这几个y是干嘛的,还有rubberBandRate()

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

请问,是不是设置了下拉刷新的宏,但是没有添加下拉刷新啊?

from swipetableview.

CoderJackie avatar CoderJackie commented on May 22, 2024

我记得没有设置宏啊,我看你的源码swipeTableVIew里面,没有判断每个item是否设置了bounce啊,那么向下滑动还会去掉bounce效果么

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

如果拖动item下拉的话,bounce的效果是由scrollview自己控制的。如果拖动的是STHeaderView的话,min 与max的代理是提供header可以正常滚动的行程范围,一旦过了这个范围,如果仍然是拖拽的话,就会对拖拽偏移量做减小的调整,来达到UIScrollView那种边界拖拽的bounce效果,如果在没有到达边界的时候松手但是有惯性的,STHeaderView会模拟UIScrollView实现惯性减速以及回弹的效果。但是如果设置了#define ST_PULLTOREFRESH_HEADER_HEIGHT的宏的话,向下拖动header一旦超过这个范围,模拟UIScrollView的惯性回弹效果就会取消。

from swipetableview.

CoderJackie avatar CoderJackie commented on May 22, 2024

我设置了item.bounce = NO;滑动header还是可以一直向下拉,没有去除bounce效果,我明天再看看我是不是设置了refreshHeader的宏。

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

好的。
这个项目只是干预了item的offset与contentsize,如果设置了宏同时也占用了tableheaderview。
另外,如果你的不是最新版本的话,你可以试着升级到最新版本试试。最新的版本中也增加了下拉的代理,能更灵活的控制每个item的下拉。

from swipetableview.

CoderJackie avatar CoderJackie commented on May 22, 2024

我分别设置了item的bounce=NO,上下拖动item是不会有bounce效果,但是拖动STHeaderView还是会有bounce效果,要修改源码中的STHeaderView的maxFrameOrginY?

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

你是不想要bounce效果?

from swipetableview.

CoderJackie avatar CoderJackie commented on May 22, 2024

是的,我要向下滑动一定程度后,不再可以继续下滑。用UIScrollView的办法就是判断contentOffsetY的值,然后设置bounce效果。

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

这需要自己做stheader的代理处理。不过,你bounce效果取消了,不就连回弹也没有了嘛。这样子的话,这个取消bounce的点只能是临界点以内才行啊

from swipetableview.

CoderJackie avatar CoderJackie commented on May 22, 2024

是啊,设置bounce后没有回弹,不知道贴吧是咋做的,回弹效果也是自己做的吧

from swipetableview.

liangdrime avatar liangdrime commented on May 22, 2024

这是我写的一个解决方案,你可以参考一下,至于回弹什么的,你需要根据你自己的需求再研究一下

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    // init swipetableview
    self.swipeTableView = [[SwipeTableView alloc]initWithFrame:self.view.bounds];
    _swipeTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    _swipeTableView.delegate = self;
    _swipeTableView.dataSource = self;
    _swipeTableView.shouldAdjustContentSize = YES;
    _swipeTableView.swipeHeaderTopInset = 0;
    self.swipeTableView.swipeHeaderBar = self.segBar;
    self.swipeTableView.swipeHeaderView = self.headerView;
    [self.view addSubview:_swipeTableView];


    // Your max offset for drag
    _myMaxOffsetY = 64;

    // After set header, change the delegate to self.(must do this after set header)
    _headerView.delegate = self;

}

#pragma mark - 
- (CGPoint)minHeaderViewFrameOrgin {
#if !defined(ST_PULLTOREFRESH_HEADER_HEIGHT)
    CGFloat minOrginY = - ((_swipeTableView.currentItemView.contentSize.height + _headerView.frame.size.height + _segBar.frame.size.height) - _swipeTableView.currentItemView.bounds.size.height);
#else
    CGFloat minOrginY = - (_swipeTableView.currentItemView.contentSize.height - _swipeTableView.currentItemView.bounds.size.height);
#endif
    // 'fmin' is used to fix the case when contentSize is smaller than bounds
    minOrginY = fmin(minOrginY, _myMaxOffsetY);
    return CGPointMake(0, minOrginY);
}

- (CGPoint)maxHeaderViewFrameOrgin {
    // Change the y is your offset
    return CGPointMake(0, _myMaxOffsetY);
}

- (void)headerViewDidFrameChanged:(STHeaderView *)headerView {
    // First adjust frame of header
    CGRect frame  = self.headerView.frame;
    CGPoint maxFrameOrgin  = [self maxHeaderViewFrameOrgin];

    if (frame.origin.y > maxFrameOrgin.y) {
        frame.origin  = CGPointMake(frame.origin.x, maxFrameOrgin.y);

        // Reset frame
        _headerView.frame = frame;

        // Cancel dynamic animation
        [_headerView endDecelerating];
    }

    // Call method `headerViewDidFrameChanged:` of swipetableview to change item contentOffset
    [_swipeTableView performSelector:@selector(headerViewDidFrameChanged:) withObject:headerView];
}

from swipetableview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.