东莞网站建设网站高德是中国的还是外国的
news/
2025/9/23 5:00:00/
文章来源:
东莞网站建设网站,高德是中国的还是外国的,网站开发人员分工,wordpress5.2 注册验证一般情况下#xff0c;UITableViewStylePlain和UITableViewStyleGrouped是UITableView常用到的style#xff0c;
之前都是用到的时候#xff0c;遇到问题直接用度娘#xff0c;差不多就够用了#xff0c;今天在修复UI提出的间隙问题#xff0c;来回改#xff0c;总觉得…一般情况下UITableViewStylePlain和UITableViewStyleGrouped是UITableView常用到的style
之前都是用到的时候遇到问题直接用度娘差不多就够用了今天在修复UI提出的间隙问题来回改总觉得没有改到命点。
下面是UI提出的要求 我项目里的代码片段是这样的 self.tableView [[UITableView alloc]initWithFrame:(CGRectZero) style:(UITableViewStyleGrouped)];[self.view addSubview:self.tableView];[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {make.left.right.bottom.equalTo(0);make.top.equalTo(([UIDevice SafeAreaNaviHeight]));}];self.tableView.delegate self;self.tableView.dataSource self;self.tableView.tag 10000;self.extendedLayoutIncludesOpaqueBars YES;if (available(iOS 11.0, *)) {[self refreshStableTableView:self.tableView];} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored -Wdeprecated-declarationsself.automaticallyAdjustsScrollViewInsets NO;
#pragma clang diagnostic pop}if (available(iOS 15.0, *)) {//适配15之后headerHeight会默认22self.tableView.sectionHeaderTopPadding 0;}self.tableView.contentInset UIEdgeInsetsMake(7, 0, UIDevice.SafeAreaBottom 49, 0);self.view.backgroundColor self.tableView.backgroundColor [UIColor useLight:HexColor(blk_6) Dark:HexColor(d_blk_6)];self.tableView.separatorStyle UITableViewCellSeparatorStyleNone; UITableView用的style是UITableViewStyleGrouped
也在代理里设置了
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{return [UIView new];
}
//
- (UIView *)tableView:(UITableView *)tableView viewForFoooterInSection:(NSInteger)section{return [UIView new];
}
//
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{return .01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{return .01;
}
感觉看着没有啥问题所以来回试第一次改的时候是动了个歪脑筋
将tableView的contentInset硬生生的改了一下看起来大概达到UI的要求了可能可以骗过UI吧但是骗不了自己这个间距并不精确。
self.tableView.contentInset UIEdgeInsetsMake(7, 0, UIDevice.SafeAreaBottom 49 - 7, 0);
一直没有往tableFooterView上想那是因为我一直以为代理里的viewForFooterInSection和tableView的tableFooterView是一个东西。
查完之后大致知道了这两的区别
tableFooterView是整个tableView的footerView
代理创建的是每个section的footerView。
UITableView的style是UITableViewStyleGrouped的时候tableFooterView会有个默认的高度需要给tableFooterView一个view来实现自己的需求当设置
self.tableView.tableFooterView [UIView new];
不起作用。因为系统检测到高度为0时会使用默认高度。所以在我的项目里需要做如下设置才能精确符合UI的要求
self.tableView.tableFooterView [[UIView alloc]initWithFrame:(CGRectMake(0, 0, SCREEN_WIDTH, 7))];
代理里的viewForFooterInSection如果不设置的话会有个默认的空白高度想要去除或者想要指定的高度那需要自己去实现代理
如果是要去掉每个section的高度则在DataSourse的heightForFooterInSection return 0.01不要return 0不然会觉得没有设置高度变成默认的高度。为了保险起见同时在Delegate的viewForFooterInSection默认return [UIView new]确保高度设置为0.01成功这样就可以了。
tableHeaderView同理。
后期会把遇到的关于UITableView不同的style的不同设置也慢慢记录下来方便自己理解省的每次都是好像懂了又好像还是啥也不懂。
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/911417.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!