OGeek|极客世界-中国程序员成长平台

标题: iphone - UITableViewController 使用大表页脚滚动太多 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 08:57
标题: iphone - UITableViewController 使用大表页脚滚动太多

我有一个 UITableViewController 子类用于输入我的应用程序的设置。我将自定义按钮添加到表页脚,方法是将它们添加到我在调用 tableView:viewForFooterInSection: 时返回的 View 中。

- (UIView *)tableViewUITableView *)tableView viewForFooterInSectionNSInteger)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 actionselector(testConnectionClicked forControlEvents:UIControlEventTouchUpInside];
    [button release];

    if (!_settings.isNew)
    {
    // I add another button
    }

    return [view autorelease];
}

- (CGFloat)tableViewUITableView *)tableView heightForFooterInSectionNSInteger)section 
{
    return _settings.isNew ? 50 : 110;
}

从 UITableViewController 子类化的重点是避免在键盘出现时让单元格滚动到 View 中的问题。

这基本上可以正常工作,但是当编辑移动到最后一个单元格时,它似乎试图将表格页脚滚动到 View 中。这意味着当在 iPhone 上以横向 View 时,它实际上会将编辑文本字段滚动到 View 之外。



Best Answer-推荐答案


我通过在 tableviewcontrollertableview 下面添加一个额外的 UIView 解决了这个问题,而不是在我最后一个 tableviewcontroller 的页脚中设置一些文本code>tableview 部分。

如果您希望在多个部分中使用该页脚,这当然不能解决您的问题。

关于iphone - UITableViewController 使用大表页脚滚动太多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7222643/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4