tableView 分组间距
来源:互联网 发布:windows tracert 多个 编辑:程序博客网 时间:2024/05/21 15:50
在使用IOS的UITableView时,时常会用到它的UITableViewStyleGrouped分组多section属性。而默认的情况下使用该属性后section之间的间距会比较大,看着很不舒服。那么可以通过以下的代理方法配置UITableView各个section的间距。
原理其实很简单,显示效果的各个section间距其实是section头部和底部的组合。配置他们的间距就是配置各个section的头部和底部。具体如下示例:
折叠展开C/C++ Code复制内容到剪贴板
//section头部间距
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 1;//section头部高度
}
//section头部视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
view.backgroundColor = [UIColor clearColor];
return [view autorelease];
}
//section底部间距
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 1;
}
//section底部视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
view.backgroundColor = [UIColor clearColor];
return [view autorelease];
}
原理其实很简单,显示效果的各个section间距其实是section头部和底部的组合。配置他们的间距就是配置各个section的头部和底部。具体如下示例:
折叠展开C/C++ Code复制内容到剪贴板
//section头部间距
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 1;//section头部高度
}
//section头部视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
view.backgroundColor = [UIColor clearColor];
return [view autorelease];
}
//section底部间距
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 1;
}
//section底部视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
view.backgroundColor = [UIColor clearColor];
return [view autorelease];
}
0 0
- tableView 分组间距
- tableView组间距
- [IOS]Tableview分组
- tableView分组 头部悬停
- iOS tableView分组
- 使用TableView进行分组
- 调整tableView的section间距的方法
- Tableview自定义分组头,分组尾
- 实现可折叠的分组tableview
- tableView分组显示,悬挂效果
- 【iOS】iOS开发TableView分组
- tableView分组头部标题处理
- tabLeview的静态分组使用
- 表格 改变分组列表之间的间距
- ios7设置group类型tableview的section间距
- 关于tableView样式为UITableViewStyleGrouped间距的设置
- iOS解决tableView左边分割线有间距问题
- iOS 设置group类型tableview的section间距
- Hibernate事务与并发问题处理(乐观锁与悲观锁)
- 工程人员注意事项
- iOS的网路请求
- 关于code first 创建并更改已经创建好的数据库的方法【本人真实操作】
- 基于Mahout的图书推荐系统
- tableView 分组间距
- 开发基本守则
- 基于Docker的PHP开发环境
- C++ 类的 复制构造函数 和 赋值构造函数
- WPF无边框窗体-可移动可调整大小
- Android Studio中如何跳到某一个方法
- linux下操作cpu寄存器
- codeforces 496C Removing Columns (模拟,思维)
- php变量什么情况下加大括号{}