سؤال

Example of ios table with partially hidden header

Here you can see that top section header partially hidden, it has the same size as next one but part of it is hidden behind the table frame. If I set its size to 40 it's will be completely hidden. Can someone explain what is happening? I've moved the table down to not think that its edge is under nav bar. Style of table is plain.

The code for table delegate:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{return 2;}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(section == 0)
        return 8;
    if(section == 1)
        return 16;
    return 0;
}

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

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

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 70)] autorelease];
    [view setBackgroundColor:[UIColor grayColor]];
    return view;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"reuse"] autorelease];
    cell.textLabel.text = [NSString stringWithFormat:@"%i", indexPath.row];
    return cell;
}
هل كانت مفيدة؟

المحلول

There must be offset set to scroll view. Look through your code where you using this controller. Maybe you missed it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top