Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7

前端 未结 30 2933
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 12:47

Starting in iOS7, there is additional space at the top of my UITableView\'s which have a style UITableViewStyleGrouped.

Here is an example:<

30条回答
  •  不要未来只要你来
    2020-11-22 13:21

    I'm assuming that is just part of the new UITableViewStyleGrouped styling. It is in all grouped table views and there doesn't seem to be any direct way to control that space.

    If that space is being represented by a UIView, it would be possible to search through all the subviews of the UITableView to find that specific view and edit it directly. However, there is also the possibility that that space is just a hardcoded offset before headers and cells start and there won't be any way to edit it.

    To search through all subviews (I would run this code when the table has no cells, to make it a little easier to read the output):

    - (void)listSubviewsOfView:(UIView *)view {
    
        // Get the subviews of the view
        NSArray *subviews = [view subviews];
    
        // Return if there are no subviews
        if ([subviews count] == 0) return;
    
        for (UIView *subview in subviews) {
    
            NSLog(@"%@", subview);
    
            // List the subviews of subview
            [self listSubviewsOfView:subview];
        }
    }
    

提交回复
热议问题