我有一个分组表。我对这张表有两条规则,在第一个条件下,我需要在页脚中显示一张漂亮的图片(这行得通)。在第二种情况下,我需要在页脚中显示一些文本(失败)。是否可以在同一张桌子上使用titleForFooterInSection
和?viewForFooterInSection
如果我同时在同一部分使用它们,应该优先使用哪一个?
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
if (section < self.practiceLessonSet.lessons.count) {
if ([[self.practiceLessonSet.lessons objectAtIndex:section] words].count == 1) {
return @"No replies yet. Try the share button?";
}
}
return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
if (self.practiceLessonSet.lessons.count == 0) {
UIImageView *view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"introPractice"]];
view.contentMode = UIViewContentModeCenter;
return view;
} else
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (self.practiceLessonSet.lessons.count == 0)
return 278;
else
// WHAT SHOULD I PUT HERE?
return [super tableView:tableView heightForFooterInSection:section]; // <-- FAILS
}