Comments (8)
#3 在你最新的分支上,怎么修改悬浮问题啊
from swipetableview.
你好,你录得视频,是在你没有把bar放在header上的时候吧?
如果把bar放在header了,相当于没有了bar,也就不存在悬停bar的情况了。只是在处理header的frame了。
我下载了你提供的demo,bar也没有悬停功能了。只是在左右滑动切换item的时候,顶部insert的计算还是以_swipeHeaderTopInset
为准导致header下部停留在_swipeHeaderTopInset
高度的位置。
你再看一下,咱俩统一一下问题点,然后我解决一下。
from swipetableview.
是的,应该是监听contentSize的时候
#if !defined(ST_PULLTOREFRESH_HEADER_HEIGHT)
CGFloat topMarginOffset = _swipeHeaderTopInset + _barInset;
DLog(@"newOffsetY -- %f", newOffsetY);
DLog(@"topMarginOffset -- %f", topMarginOffset);
// stick the bar
if (newOffsetY < - topMarginOffset) {
if (_swipeHeaderBar) {
_swipeHeaderBar.st_bottom = - newOffsetY;
_swipeHeaderView.st_bottom = _swipeHeaderBar.st_top;
}else {
_swipeHeaderView.st_bottom = - newOffsetY;
}
}else {
_swipeHeaderBar.st_bottom = topMarginOffset;
// 'fmax' is used to fix the bug below iOS8.3 : the position of the bar will not correct when the swipeHeaderView is outside of the screen.
_swipeHeaderView.st_bottom = fmax(- (newOffsetY + _barInset), 0);
}
#else
不知道我要根据什么去改变_swipeHeaderView.st_bottom,我如果创建swipeTableView,swipeHeaderTopInset为0时,header的底部是正常的,但是导航栏就会盖住视图上面的64了。我的导航栏高度是动态变化的,那是不是要动态设置swipeHeaderTopInset,但我又发现每次设置swipeHeaderTopInset时都会去reload。
from swipetableview.
如果是刚才我说的那个问题的话。那么现在有两个解决办法
首先说明一下,header与bar的悬停都是根据swipeHeaderTopInset
来设置的,这个值属性就是为了给顶部留一个空白,一般是导航栏高度,而header与bar的位置总是要悬停在这个位置的。所以,根据你的需求需要做修改处理。
第一种,相对来说是笨方法,就是把swipeHeaderTopInset
同样设置为0,这样header就会隐藏在导航栏下。为了解决这个问题,可以把自己定义的header的高度比自己需要的高度增加64,然后所有内部控件的布局的位置从64的高度开始。这样,虽然header的位置是在0,但是内容的位置却是在64的位置。
另一种,需要修改代码了。因为heade的位置是根据swipeHeaderTopInset
来设置的,其中就是在滑动的时候adjust方法中计算的。而swipeHeaderTopInset
,在cellforrow中,会根据这个数值给每个item顶部增加contentInset的top值的。所以,针对你的需求,这两处冲突了。
可以设置两个属性,一个负责在cellforrow中对每个item的contentInset的top值调整,一个负责在adjust计算中负责计算相邻item顶部的初始位置。这样,可以把swipeHeaderTopInset
,作为contentInset的top值,设置另一个属性在adjust中作为计算顶部位置的值,替换adjust中的swipeHeaderTopInset
,或者因为你的需求,可以简单粗暴的直接把adjust中的swipeHeaderTopInset
替换为0即可。
from swipetableview.
刚刚测试了一下,在两个adjust中修改如下即可(注意:在lastIndex == index
条件下,属于init初始化,这里的swipeHeaderTopInset
不要改为0,如果你页面默认一开始是显示导航栏的)
- (void)adjustItemViewContentOffset:(UIScrollView *)itemView atIndex:(NSInteger)index fromLastItemView:(UIScrollView *)lastItemView lastIndex:(NSInteger)lastIndex {
......
// 取出记录的offset
#if !defined(ST_PULLTOREFRESH_HEADER_HEIGHT)
CGFloat topMarginOffsetY = - (_swipeHeaderTopInset + _barInset);
#else
CGFloat topMarginOffsetY = _headerInset - 0;
#endif
NSValue *offsetObj = [self.contentOffsetQuene objectForKey:@(index)];
CGPoint itemContentOffset = [offsetObj CGPointValue];
if (nil == offsetObj) { // init
itemContentOffset.y = topMarginOffsetY;
}
.....
}
如果,是自适应的contentsize也是充满屏幕,即使隐藏了导航栏,下面adjust contentsize的方法也要修改
- (void)adjustItemViewContentSize:(UIScrollView *)itemView atIndex:(NSInteger)index {
// get the min required height of contentSize
#if !defined(ST_PULLTOREFRESH_HEADER_HEIGHT)
CGFloat minRequireHeight = itemView.st_height - (0 + _barInset);
#else
CGFloat minRequireHeight = itemView.st_height - 0 + _headerInset;
#endif
.....
from swipetableview.
我试了第二种,你贴的代码是可以的,等一下我试试第一种,还是不改里面源码的好。多谢了,等一下我仔细读读你写的评论,再研究下源码。我也看了一上午源码,但是各种contentInset,offset ,contentSize,弄的有点晕。
from swipetableview.
写的还是不好,多见谅😃
from swipetableview.
太谦虚了,还要多谢你的及时回复。回复的好认真。。
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.