5

I have a UITabBarController with two UITableViews, all were created in the storyboard.

The problem is that in the second tableview the first few lines of the table are under the top bar, this doesn't happens with the first tableview, even if I change the order of the views the first will work perfectly and the second will present the problem, so the one that was working perfectly now presents the same problem because is the second item of the tabbar controller.

I don't have much code to show because I didn't create the tableviews programatically.

Sebastian
  • 7,670
  • 5
  • 38
  • 50
Boris
  • 11,373
  • 2
  • 33
  • 35
  • I'll suggest you to create tableView programatically so that you'll have more control on both the tables. You can set different frame sizes for both tables and avoid this issue. – Zac24 Dec 04 '13 at 11:53
  • Thanks for you answers... I accepted user1550961 answer, disabling the "extend edges" option fixed the issue – Boris Dec 16 '13 at 05:03

2 Answers2

9

Not sure exactly based on your description, but a couple possibilities come to mind:

  1. Check your view controller attributes inspector in IB. Look for "Extend Edges" option under View Controller, and uncheck "Under Top Bars" if it is checked.

  2. In ios7, there appears to be a behavior in UIScrollView and all subclasses whereby the content inset and offset is automatically adjusted, sometimes not very well. You can try disabling that either in code or IB (see link for how: iOS 7 -- navigationController is setting the contentInset and ContentOffset of my UIScrollView)

Community
  • 1
  • 1
FeichengMaike
  • 438
  • 3
  • 9
0

For any newly created iOS >7.0 app I suggest you take a deeper look at autolayout. For all my old iOS 6 apps I solved it like this:

In your UITableViewController interface:

  bool _hasStatusBar;
  bool _hasStatusBarHeight;
  UIView *_blendView;

In your UITableViewController implementation file:

-(void)viewWillAppear:(BOOL)animated{
  _hasStatusBar = NO;
  _blendView = nil;
  [self.tableView reloadData];
}

-(void)viewWillDisappear:(BOOL)animated{
  _hasStatusBar = NO;
  _blendView = nil;
}

- (void) viewDidLayoutSubviews {
    // WTF APPLE!?
  if (!_hasStatusBar) {

    int topBarOffset = 20;

    _hasStatusBar = YES;
      // Fix for iOS 7 overlaying status bar
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {

      CGRect viewBounds = self.view.bounds;
      _blendView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewBounds.size.width, topBarOffset)];
      [_blendView setBackgroundColor:COLOR_MAIN];
      [_blendView setOpaque:YES];
      [_blendView setAlpha:1.00];
      UIView *whityMacWhite = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewBounds.size.width, topBarOffset)];
      [whityMacWhite setBackgroundColor:[UIColor whiteColor]];
      [whityMacWhite setOpaque:NO];
      [whityMacWhite setAlpha:0.80];
      [_blendView addSubview:whityMacWhite];
      [self.view.superview addSubview:_blendView];
    }
  }
}
Git.Coach
  • 3,032
  • 2
  • 37
  • 54