Comments (14)
很抱歉,我不是很清楚你说的垂直方向bounce是什么意思。如果说每个item的话,默认都是有的。你能具体描述一下你的问题吗?
from swipetableview.
我设置了每个item的bounce,但是只有上拉的时候有效果,下拉的时候,顶部还是可以继续拉
from swipetableview.
所以我考虑应该是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.
请问,是不是设置了下拉刷新的宏,但是没有添加下拉刷新啊?
from swipetableview.
我记得没有设置宏啊,我看你的源码swipeTableVIew里面,没有判断每个item是否设置了bounce啊,那么向下滑动还会去掉bounce效果么
from swipetableview.
如果拖动item下拉的话,bounce的效果是由scrollview自己控制的。如果拖动的是STHeaderView的话,min 与max的代理是提供header可以正常滚动的行程范围,一旦过了这个范围,如果仍然是拖拽的话,就会对拖拽偏移量做减小的调整,来达到UIScrollView那种边界拖拽的bounce效果,如果在没有到达边界的时候松手但是有惯性的,STHeaderView会模拟UIScrollView实现惯性减速以及回弹的效果。但是如果设置了#define ST_PULLTOREFRESH_HEADER_HEIGHT
的宏的话,向下拖动header一旦超过这个范围,模拟UIScrollView的惯性回弹效果就会取消。
from swipetableview.
我设置了item.bounce = NO;滑动header还是可以一直向下拉,没有去除bounce效果,我明天再看看我是不是设置了refreshHeader的宏。
from swipetableview.
好的。
这个项目只是干预了item的offset与contentsize,如果设置了宏同时也占用了tableheaderview。
另外,如果你的不是最新版本的话,你可以试着升级到最新版本试试。最新的版本中也增加了下拉的代理,能更灵活的控制每个item的下拉。
from swipetableview.
我分别设置了item的bounce=NO,上下拖动item是不会有bounce效果,但是拖动STHeaderView还是会有bounce效果,要修改源码中的STHeaderView的maxFrameOrginY?
from swipetableview.
你是不想要bounce效果?
from swipetableview.
是的,我要向下滑动一定程度后,不再可以继续下滑。用UIScrollView的办法就是判断contentOffsetY的值,然后设置bounce效果。
from swipetableview.
这需要自己做stheader的代理处理。不过,你bounce效果取消了,不就连回弹也没有了嘛。这样子的话,这个取消bounce的点只能是临界点以内才行啊
from swipetableview.
是啊,设置bounce后没有回弹,不知道贴吧是咋做的,回弹效果也是自己做的吧
from swipetableview.
这是我写的一个解决方案,你可以参考一下,至于回弹什么的,你需要根据你自己的需求再研究一下
- (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)
- 给继承自STCollectionView 的collectionview 添加MJRefreshHeader 下拉刷新回弹位置错误 HOT 1
- 使用方法还是太不方便了
- alwaysBounceHorizontal 属性没有效果
- 添加mj_header位置问题 HOT 1
- reoloadData无效
- swipeTableViewWillBeginDragging不响应
- Tableview的点击
- Multiple methods named 'frame' found with mismatched result, parameter type or attributes HOT 2
- MJRefresh上拉加载更多 偏移量问题 HOT 2
- 动态修改headview高度的时候显示不正确
- 没有用autolayout的后果
- iOS12 - iPhoneXS 右滑crash HOT 3
- 从别的页面返回更新headerView的高度时布局不对 HOT 1
- 提两点功能补充
- iPhone X适配 和 sectionHeader问题
- iOS 8 crash
- STHeaderView 手势冲突问题
- 如果进入页面,想指定某一个item展示,而不是默认第一个item0,怎么处理?是不是应该暴露一个selectedIndex HOT 1
- attempt to scroll to invalid index path:
- 在维护App的时候,发现了前人集成了这个东西,代码耦合度高的吓人,还很容易触发异步刷新的crash问题,虽然我做了很多修改,源码也做了修改。controller 代码就有5000行,我是心力交瘁啊 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swipetableview.