Offset when displaying UITableView

I am showing a UITableView and from time to time the first row appears at the bottom of the view.

There is nothing above the first line and white space is insensitive.

So far I have checked:

  • headerView tableView: empty
  • use a simple UITableViewCells
  • check stringHight from cells
  • check cell frame
  • when an error occurs, a memory save warning before
  • check the contents of the table scrolling view object

This error only appears on iPhone, never on a simulator.

The screenshot on the left shows the correct table view, and the right shows the error view. When you take a photo, I touched the screen so that the scroll bar is visible.

Any idea which direction I should be looking in?

I just saw that the contentSize of the tableView scrollView is wrong: I have 84 cells @ 67px and 1 cell @ 57px height: the total should be 5685 but equal to 6005. (off at 320). It's strange.

Stephan

alt text http://www.quicksnapper.com/files/5161/18374733084A0B3EA24D152.png

0


a source to share


2 answers


So I found the solution to my problem:

Adding NSLog (@ ""). This is strange.

In my WillAppear view I have

  if (searchByCuisinier || searchByResto) {
    NSLog(@"Will set tableHeaderView");
    self.tableView.tableHeaderView = searchBar;
    if (searchByCuisinier) {
      searchBar.placeholder = @"Cuisinier";
    } else {
      searchBar.placeholder = @"Restaurant";
    }
    searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
    searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
    if ([filteredList count] == 0)
      [searchBar becomeFirstResponder];
  } else {
    self.tableView.tableHeaderView = nil;
    NSLog(@""); // Magic!
  }

      

Adding NSLog (@ "") solves the problem.



Also reversing the test: Instead of

  if (searchByCuisinier || searchByResto) {
....

      

I am doing:

  if (!searchByCuisinier && !searchByResto) {
....

      

I have absolutely no idea why this works (or why it doesn't work without NSLog).

0


a source


You can override the touchhesBegan method on the UITableView and then run the hit test.

Then ask what kind the class returned.



- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

CGPoint location = [[touches anyObject] locationInView:self]; 

UIView *whatIsThis = [self hitTest:locationInView withEvent:event];

NSLog([[whatIsThis class] description]);


}

      

At least you will have a starting point. You can also ask who has a supervisor.

+1


a source







All Articles