【问题标题】:UITableView section header missplacedUITableView 部分标题错位
【发布时间】:2014-03-06 14:12:23
【问题描述】:

我的 UITableView 出现了非常奇怪的错误。我正在使用标准视图和部分。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44.0f;
}

- (NSString*) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
switch (section)
{
    case kSectionProfile:
        return @"Profile";
        break;

    case kSectionContacts:
        return @"Contacts";
        break;

    case kSectionApps:
        return @"Apps";
        break;

    case kSectionSettings:
        return @"Settings";
        break;

    case kSectionCount:
        return nil;
        break;
}

return nil;
}

TableView 来自 XIB。

模拟器:

这是 UITableView 的顶部,部分永远不会触及可见区域的顶部,并且单元格是围绕部分标题绘制的。 我不知道是什么导致了这个奇怪的问题。 UITableView 的顶部似乎没有正确计算。

【问题讨论】:

    标签: ios objective-c uitableview


    【解决方案1】:

    更新: 在层次结构中的 VC 对象上取消选中 storyboard/XIB 中的以下框。

    从这里:UITableView is starting with an offset in iOS 7

    旧答案:

    使用- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section委托方法,看看是否有帮助。

    例如

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        return 20.0f;
    }
    

    【讨论】:

    • 已经试过了 - 不能解决任何问题 - 只是让标题变大,但它们仍然没有触及桌面
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-02
    • 2012-04-05
    • 1970-01-01
    • 1970-01-01
    • 2017-02-09
    相关资源
    最近更新 更多