0

This code works: [self.tableView reloadData], but if I extend the loadView method of UITableViewController like this:

- (void) loadView {
    [super loadView];
    float headerHeight = 80;
    UIView *tableV = self.tableView;
    CGRect tableFrame = self.tableView.frame;

    self.view = [[UIView alloc] initWithFrame:self.tableView.frame];
    [self.view release];

    tableFrame.origin.y += headerHeight - [UIApplication sharedApplication].statusBarFrame.size.height;
    tableFrame.size.height -= headerHeight;
    tableV.frame = tableFrame;
    [self.view addSubview:tableV]; 
}

the tableView data isn't reload. What am I doing wrong?

msgambel
  • 7,320
  • 4
  • 46
  • 62
Artur Gurgul
  • 396
  • 4
  • 21

1 Answers1

0

In a UITableViewController, self.view == self.tableView, so in line 7 (self.view = [[UIView...) you're actually replacing both self.view and self.tableView.

If all you want is to move the table view down, try using contentInset.

Can Berk Güder
  • 109,922
  • 25
  • 130
  • 137
  • yes, self.view == self.tableView, but after super method i change it. Property self.view store reference to another object (i checked it) Ewerything look fine, but not reload Data – Artur Gurgul Aug 27 '11 at 20:49
  • self.view points to your newly created UIView, but self.tableView is null. – Can Berk Güder Aug 27 '11 at 20:53