iOS开发:Xcode 7之后viewForHeaderInSection、viewForFooterInSection设置内容不产生效果的解决方法
2018-01-11 16:25
771 查看
之前使用viewForHeaderInSection和viewForFooterInSection的时候,可以直接设置headerView和footerView的属性、颜色等,但是之后发现直接设置不了这些属性了,按照之前的设置之后运行没有修改之后的效果:
如果直接使用上面的方法,不产生任何修改之后的效果;那么怎么解决呢,请看下面的解决方法。
解决方法就是,在写上面两个方法的同时,必须要指定它们的titleForHeaderInSection、titleForFooterInSection字符串,这样才能让你设置的效果显示出来,具体操作如下:
最新的正确的一整套的操作步骤如下,其实也很简单,只是要注意一下,如下所示:
代码如下:
-
(UIView *)tableView:(UITableView *)
4000
tableView viewForHeaderInSection:(NSInteger)section
{
UIView *header =
[UIView new];
header.backgroundColor =
[UIColor yellowColor];
return header;
}
-
(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *footer =
[UIView new];
footer.backgroundColor =
[UIColor orangeColor];
return footer;
}
-
(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @" ";
}
-
(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
return @" ";
}
如果想更进一步的进行交流探讨,请加本人微信公众号,又更多的技术分享等着你来,欢迎关注!
如果直接使用上面的方法,不产生任何修改之后的效果;那么怎么解决呢,请看下面的解决方法。
解决方法就是,在写上面两个方法的同时,必须要指定它们的titleForHeaderInSection、titleForFooterInSection字符串,这样才能让你设置的效果显示出来,具体操作如下:
最新的正确的一整套的操作步骤如下,其实也很简单,只是要注意一下,如下所示:
代码如下:
-
(UIView *)tableView:(UITableView *)
4000
tableView viewForHeaderInSection:(NSInteger)section
{
UIView *header =
[UIView new];
header.backgroundColor =
[UIColor yellowColor];
return header;
}
-
(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *footer =
[UIView new];
footer.backgroundColor =
[UIColor orangeColor];
return footer;
}
-
(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @" ";
}
-
(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
return @" ";
}
如果想更进一步的进行交流探讨,请加本人微信公众号,又更多的技术分享等着你来,欢迎关注!
相关文章推荐
- 【iOS开发】关于Xcode8后产生的viewForHeaderInSection、viewForFooterInSection设置不产生效果的问题
- ios开发之--ios11适配:TableView的heightForHeaderInSection设置高度无效/UISearchBar消失
- iOS开发-设置headerInsectionView不悬浮
- 【iOS】tableView:viewForHeaderInSection: 方法未调用
- iOS开发-设置headerInsectionView不悬浮
- ios:改变tableview的titleForHeaderInSection字体颜色设置
- iOS开发——heightForHeaderInSection设置高度无效
- iOS开发UI— QQ好友列表(处理头部控件的点击)viewForHeaderInSection:
- iOS UITableView:section的Header以及Footer不悬浮停留在屏幕的方法(非在scrollView代理实现的方法)
- iOS开发79-Xcode报错:The file “XXX” couldn’t be opened because you don’t have permission to view it.的解决方法
- iOS开发笔记--解决UITableView中Cell重用机制导致内容出错的方法总结
- iOS tableview viewForHeaderInSection 自定义
- iOS开发 TableView的headerInSectionView 不悬浮
- ios UIImageView添加图片动画效果,添加了手势之后,依然没有反应的解决方法
- iOS开发笔记--解决UITableView中Cell重用机制导致内容出错的方法总结
- UITableView的section设置了headerView导致下滑的时候headerView跟着滚动的解决方法
- iOS开发笔记--解决UITableView中Cell重用机制导致内容出错的方法总结
- UITableView的代理方法viewForHeaderInSection不执行的原因
- UITableView的代理方法viewForHeaderInSection不执行的原因
- Android ListView在增加HeaderView之后使用getLocationInWindow和getLocationOnScreen获得值不正确的解决方法