我有一个UITableViewController子类,用于输入我的应用程序的设置。我将自定义按钮添加到表脚,方法是将它们添加到我在调用tableView:viewForFooterInSection:时返回的视图中。
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
CGRect viewRect = self.view.bounds;
float height = _settings.isNew ? 50.0 : 110.0;
float margin = (viewRect.size.width > 480.0) ? 44.0 : 10.0;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, height)];
GradientButton* button = [[GradientButton alloc] initWithFrame:CGRectMake(margin, 5, viewRect.size.width - margin * 2, 44)];
[view addSubview:button];
[button addTarget:self action:@selector(testConnectionClicked:) forControlEvents:UIControlEventTouchUpInside];
[button release];
if (!_settings.isNew)
{
// I add another button
}
return [view autorelease];
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return _settings.isNew ? 50 : 110;
}从UITableViewController派生子类化的全部目的是为了避免在键盘出现时将单元格滚动到视图中时出现问题。
这在很大程度上是正常工作的,但是当编辑移动到最后一个单元格时,它似乎会尝试将表格页脚滚动到视图中。这意味着当在横向视图中的iPhone上时,它实际上将编辑文本字段滚动出视图。
发布于 2012-12-13 20:48:08
我通过在tableviewcontroller中的tableview下面添加一个额外的UIView来解决这个问题,而不是在最后一个tableview部分的页脚中设置一些文本。
如果你想把页脚放在多个部分中,这当然不能解决你的问题。
https://stackoverflow.com/questions/7222643
复制相似问题