15

Iam not sure if it is the appropriate question to ask right now. I am working with Xcode 5 (preview version ) on the table view. The issue right now is if my table view is selected as group than I am having a gap between the first cell and the top edge of table.

The code for uitable view delegate is below

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 8;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *simpleTableIdentifier = @"SimpleTableItem";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }

    cell.textLabel.text = [NSString stringWithFormat:@"cell %d",indexPath.row];
    return cell;
}

Image below when I am choosing group in the xib

enter image description here

However, if i am switching to plain, table is normal

enter image description here

Any thoughts for this situation. I googled it but seems there are nothing out there. Any helps are welcomed here.

Jano
  • 62,815
  • 21
  • 164
  • 192
tranvutuan
  • 6,089
  • 8
  • 47
  • 83
  • 1
    Umm didnt you notice the settings app? I think thats how the new grouped table view works. – Desdenova Jul 16 '13 at 14:41
  • 3
    @NilsMunch this is actually a good question and should be reopened on the Sept 18th. This is not off topic by any means. http://meta.stackexchange.com/questions/94465/should-moderators-enforce-ndas-for-software-vendors – Ryan Romanchuk Sep 16 '13 at 12:55
  • 1
    Here's how I solved this problem: http://stackoverflow.com/a/18938763/588253 – Mr. T Sep 21 '13 at 23:37
  • If this was indeed closed due to Apple's information embargo, it should now be reopened. – dpassage Oct 15 '13 at 18:55
  • 1
    It works for me when I return a very small number (i.e. 0.0001f) for tableView:heightForHeaderInSection: – audub Oct 21 '13 at 19:45
  • This is not expected behaviour actually. Check my answer here http://stackoverflow.com/questions/18880341/why-is-there-extra-padding-at-the-top-of-my-uitableview-with-style-uitableviewst/21137552#21137552 – girish_vr Feb 26 '14 at 14:59

2 Answers2

20

That is the expected appearance of a grouped table view in iOS 7. If you open the Settings app you will see a similar separator bar at the top of the table and in between each section in the table view (grey in color).

Jake Spencer
  • 1,117
  • 7
  • 13
1

For the sake of being thorough you should implement the number of sections in the table view and in this case, return one. Its possible that theres a bug with Xcode 5 wherein if you do not implement that method it provides you with an incorrect header.

If that does that not solve the issue I would recommend implementing

- (UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section

That may do the trick as well.

Peter Foti
  • 5,526
  • 6
  • 34
  • 47