Open AlvinBoy opened 6 years ago
这个可以试试 设置 _swipeTableView.swipeHeaderTopInset = 0; 应该就不会出现多余的部分. 但是在cell 行数很少时, 会出现滚动超出顶部Tabbar的情况.类似#105
好的,麻烦作者了,谢谢🙏
发自我的 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.
可以尝试在自定义的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;
}
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.