IOS之UITableView的header显示问题
2015-07-01 12:02
836 查看
最近在攻克新项目,发现一个不一样的地方,觉得也许是apple的小bug吧,不确定呢。
而后,代码为
发现,显示效果,顶部没有出现预计中的账号信息header,擦,奇怪了,日志不输出出现section = 0。
而后,我又增加了代码
这时候,日志输出section = 0,并且显示出账号信息header了。
照理说,我xib中已经设置了header的height了啊,而且其他section的header显示出来了,但是就是第一个不显示出来,邪门中。
情景
使用UITableView展示列表元素信息,使用grouped方式,设置section的header,奇怪的是不显示section=0的时候的header。发现
我是通过xib配置的UITableView,在tableview的section height中修改了header的参数为30,footer为1而后,代码为
//setion数量 static const int VCInfoSectionCount = 5; //用户账户信息 static const int VCUserInfoSection = 0; //微信信息 static const int VCWeiXinInfoSection = 1; //钱包信息 static const int VCWalletInfoSection = 2; //邀请信息 static const int VCInviteInfoSection = 3; //设置信息 static const int VCSettingInfoSection = 4; ... - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 5.0f, tableView.width, 20.0f)]; if (section == 0) { NSLog(@"出现section = 0"); } if (section == VCUserInfoSection) { titleLabel.text = @"账号信息"; }else if (section == VCWeiXinInfoSection){ titleLabel.text = @"微信信息"; }else if (section == VCWalletInfoSection){ titleLabel.text = @"钱包信息"; }else if (section == VCInviteInfoSection){ titleLabel.text = @"邀请信息"; }else if (section == VCSettingInfoSection){ titleLabel.text = @"基本设置"; } titleLabel.textColor = [UIColor blueColor]; titleLabel.backgroundColor = [UIColor orangeColor]; return titleLabel; }
发现,显示效果,顶部没有出现预计中的账号信息header,擦,奇怪了,日志不输出出现section = 0。
而后,我又增加了代码
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 30.0f; }
这时候,日志输出section = 0,并且显示出账号信息header了。
照理说,我xib中已经设置了header的height了啊,而且其他section的header显示出来了,但是就是第一个不显示出来,邪门中。
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- IE:如何做到全屏显示
- 修改注册表实现在桌面上显示Windows版本
- Attrib 显示、设置或删除指派给文件或目录的只读、存档、系统以及隐藏属性
- VB的TextBox文本框实现垂直居中显示的方法
- C#实现获取系统目录并以Tree树叉显示的方法
- bat脚本显示本机IP地址的两种方法(内网ip)
- 图象函数中的中文显示
- 桌面中心(四)数据显示
- 用ODBC的分页显示
- php通过修改header强制图片下载的方法
- 显示、隐藏密码
- javascript实现点击后变换按钮显示文字的方法
- JS动态显示表格上下frame的方法