Ios UITableViewHeaderFooterView可以';从nib加载时,请不要更改自定义背景
我已经创建了一个自定义UITableViewHeaderFooterView,并成功地从nib加载到我的UITableView中,但始终收到此消息 “已在UITableViewHeaderFooterView上设置背景色 已弃用。请改用contentView.backgroundColor。“ 下面是加载自定义UITableViewHeaderFooterView的代码:Ios UITableViewHeaderFooterView可以';从nib加载时,请不要更改自定义背景,ios,uitableview,Ios,Uitableview,我已经创建了一个自定义UITableViewHeaderFooterView,并成功地从nib加载到我的UITableView中,但始终收到此消息 “已在UITableViewHeaderFooterView上设置背景色 已弃用。请改用contentView.backgroundColor。“ 下面是加载自定义UITableViewHeaderFooterView的代码: - (UIView *)tableView:(UITableView *)tableView viewForFooterIn
- (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;
}您是否在nib的页脚视图上设置了“背景色”属性?如果是,则将其设置为“默认”
<>也可以考虑做< /P>
customHeaderIphone.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"customHeader"]];
而且根本不设置背景色。根据link,这是苹果公司的首选方法。将背景颜色设置为默认值,使其像一个符咒一样工作,谢谢你:D