I've created a custom UITableViewHeaderFooterView and successfully load from nib into my UITableView but always get this message

"Setting the background color on UITableViewHeaderFooterView has been deprecated. Please use contentView.backgroundColor instead."

Here the code for loading my custom UITableViewHeaderFooterView:

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
KTHeaderFooterViewIphone customHeaderIphone* = [[[NSBundle mainBundle] loadNibNamed:@"KTHeaderFooterViewIphone" owner:self options:nil] objectAtIndex:0];
customHeaderIphone.tintColor = [UIColor whiteColor]; // this code worked, but the message above always show
customHeaderIphone.contentView.backgroundColor = [UIColor redColor]; // this code doesn't work, nothing's happened
customHeaderIphone.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"customHeader.png"]]; // this code doesn't work too, I can't change custom background image
return customHeaderIphone;

}

answer:

Did you set the "Background Color" attribute on the footer view in your nib? If so, set that to "Default".

Also you may want to consider doing

customHeaderIphone.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"customHeader"]];

and not setting the backgroundColor at all. This is Apple's preferred method according tohttps://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewHeaderFooterView_class/Reference/Reference.html#//apple_ref/occ/instp/UITableViewHeaderFooterView/backgroundView


from:http://stackoverflow.com/questions/18800743/uitableviewheaderfooterview-cant-change-custom-background-when-loading-from-nib


最新文章

  1. javascript入门:prototype和面向对象的实现
  2. Sublime text 3安装svn插件
  3. QQLogin
  4. hdu 4722 Good Numbers 数位DP
  5. Android教程说明-夜神模拟器连接IDE更新让Delphi发现你的手机或夜神模拟器
  6. 结构体的malloc与数组空间
  7. ubuntu系统安装的MySql数据库,远程不能访问的几种可能问题
  8. Java提高学习之Object(4)
  9. CSS3 总结-2
  10. 模板 manacher算法
  11. 在web应用中使用Log4j 2
  12. Golang 入门 : 映射(map)
  13. SQL 撤销索引、表以及数据库
  14. Mybatis SqlsessionFactory
  15. HDU - 4389 X mod f(x)(数位dp)
  16. There is no session with id XXX
  17. 由设置body线性背景色引发的问题-----当声明文档类型时,对body设置线性背景色,页面背景色无法整体线性过渡
  18. 【日常记录】【unity3d】 OnTriggerEnter 和 OnCollisionEnter (2D) 的区别
  19. NOIP模拟题 友好国度
  20. GIF助手激活教程(购买+激活)图文版

热门文章

  1. PSCC2019常用基础操作
  2. hibernate_06_hibernate的延迟加载和抓取策略
  3. Windbg Step 2 分析程序堆栈实战
  4. VS2010-MFC(对话框:属性页对话框及相关类的介绍)
  5. Acess link
  6. 前后端分离+本地服务实时刷新+缓存管理+接口proxy+静态资源增量更新+各种性能优化+上线运维发布——gulp工作流搭建
  7. where与having区别
  8. 继承关系中子类使用@Data注解问题
  9. CF627A Xor Equation
  10. Jmeter 录制脚本【转】