liangdrime / SwipeTableView

Both scroll horizontal and vertical for segment scrollview which have a same header. — 类似半糖、美丽说主页与QQ音乐歌曲列表布局效果,实现不同菜单的左右滑动切换,同时支持类似tableview的顶部工具栏悬停(既可以左右滑动,又可以上下滑动)。兼容下拉刷新,自定义 collectionview实现自适应 contentSize 还可实现瀑布流功能
MIT License
2.29k stars 444 forks source link

当 navigationbar 的translucent 为NO时, 出现问题.截图如下: #106

Open AlvinBoy opened 6 years ago

AlvinBoy commented 6 years ago

a

AlvinBoy commented 6 years ago

b

CXTretar commented 6 years ago

这个可以试试 设置 _swipeTableView.swipeHeaderTopInset = 0; 应该就不会出现多余的部分. 但是在cell 行数很少时, 会出现滚动超出顶部Tabbar的情况.类似#105

AlvinBoy commented 6 years ago

好的,麻烦作者了,谢谢🙏

发自我的 iPhone

在 2018年3月30日,下午3:14,Felix notifications@github.com 写道:

我模仿STCollectionView 的写法 稍微修改一下demo, 你可以这样试试. 首先设置_swipeTableView.swipeHeaderTopInset = 0; 然后在 CustomTableView.h 中增加一项属性 `@interface CustomTableView : UITableView

@property (nonatomic, assign) CGSize minRequireContentSize;

(void)refreshWithData:(id)data atIndex:(NSInteger)index; @EnD 在CustomTableView.m 文件中重写- (CGSize)contentSize { [super contentSize];

UITableViewCell *cell = [self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:_numberOfRows - 1 inSection:0]];

CGRect lastSectionRect = cell.frame; CGSize contentSize = CGSizeMake(CGRectGetWidth(self.bounds), CGRectGetMaxY(lastSectionRect)); // fit mincontentSize contentSize.width = fmax(contentSize.width, self.minRequireContentSize.width); contentSize.height = fmax(contentSize.height, self.minRequireContentSize.height);

return contentSize; }最后修改 SwipeTableView.h 中 导入CustomTableView.h 并修改这段代码 /* contentSize / else if (context == SwipeTableViewItemContentSizeContext) { // adjust contentSize if (_shouldAdjustContentSize) { // 当前scrollview所对应的index NSInteger index = _currentItemIndex; if (object != _currentItemView) { index = _shouldVisibleItemIndex; } UIScrollView scrollView = object; CGFloat contentSizeH = scrollView.contentSize.height; CGSize minRequireSize = [_contentMinSizeQuene[@(index)] CGSizeValue]; CGFloat minRequireSizeH = round(minRequireSize.height); if (contentSizeH < minRequireSizeH) { _isAdjustingcontentSize = YES; minRequireSize = CGSizeMake(minRequireSize.width, minRequireSizeH); if ([scrollView isKindOfClass:STCollectionView.class]) { STCollectionView collectionView = (STCollectionView )scrollView; collectionView.minRequireContentSize = minRequireSize; }else { CustomTableView tableView = (CustomTableView )scrollView; tableView.minRequireContentSize = minRequireSize; } dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ _isAdjustingcontentSize = NO; }); } } }` 这样子能使不复用的自定义tableview 不会出现contentsize异常, 复用的tableview 的异常尚未解决.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

CXTretar commented 6 years ago

可以尝试在自定义的TableView 的- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;方法中加入

self.estimatedRowHeight = 0;
self.estimatedSectionHeaderHeight = 0;
self.estimatedSectionFooterHeight = 0;

并且增加代理方法

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}
AlvinBoy commented 6 years ago

ok

发自我的 iPhone

在 2018年4月2日,下午2:41,Felix notifications@github.com 写道:

可以尝试在自定义的TableView 的- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;方法中加入

self.estimatedRowHeight = 0; self.estimatedSectionHeaderHeight = 0; self.estimatedSectionFooterHeight = 0; 并且增加代理方法

  • (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return CGFLOAT_MIN; }

  • (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return CGFLOAT_MIN; }

  • (UIView )tableView:(UITableView )tableView viewForFooterInSection:(NSInteger)section { return nil; }

  • (UIView )tableView:(UITableView )tableView viewForHeaderInSection:(NSInteger)section { return nil; } — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.