如何让UITableView页脚视图可见?

时间:2013-04-28 07:33:55

标签: objective-c uitableview

当我将tableview的footerView设置为:

self.tableView.tableFooterView.frame = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 45.0f);

然后我的cellCount * cellHeight> tableview.frame.size.height。 然后我发现footerView无法显示。必须拉出它显示的tableview。怎么解决?

self.tableView.tableFooterView = [[UIView alloc] init];
self.tableView.tableFooterView.backgroundColor = [UIColor orangeColor];
[self.tableView setEditing:YES animated:YES];
self.tableView.tableFooterView.frame = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, 45.0f);

//It can't to solve My Problem
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:9 inSection:0] atScrollPosition:UITableViewScrollPositionMiddle animated:YES];

1 个答案:

答案 0 :(得分:0)

创建footerView(按代码或xib)。然后使用以下委托方法:

    - (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
           return footerView.frame.size.height;
    }
    - (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
           return footerView;
    }

在您的情况下,您可能无法返回页脚的高度。