Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView is getting a gap on top [closed]

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.

like image 993
tranvutuan Avatar asked Jul 16 '13 14:07

tranvutuan


People also ask

Why is there extra padding at the top of my UITableView?

Short answer is that this extra padding is probably due to the table view header (not the section header), and that UITableView doesn't like to be assigned a header with a height of 0.0.

How do you add a space between UITableView cells?

The way I achieve adding spacing between cells is to make numberOfSections = "Your array count" and make each section contains only one row. And then define headerView and its height.


1 Answers

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).

like image 73
Jake Spencer Avatar answered Nov 08 '22 19:11

Jake Spencer