9

I have a popover with a UITableViewController as the content view controller. The table view has a UISearchBar as its header view.

Now, on iOS 6 everything looks good when the UISearchDisplayController becomes active. But, on iOS 7 there will be an extra space above the search bar.

The extra space above the search bar on iOS 7

So how can I get rid of this extra space above the search bar on iOS 7?

Hejazi
  • 16,587
  • 9
  • 52
  • 67

1 Answers1

26

The solution is to set the property edgesForExtendedLayout of the UITableViewController to UIRectEdgeNone.

- (void)viewDidLoad {
    [super viewDidLoad];

    if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) { /// iOS 7 or above
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
}

This property has the value UIRectEdgeAll by default. Which means all edges of the view will be extended to keep an extra space for the status bar (the height of the space above the search bar is exactly 20px, the same height of the status bar).

Hejazi
  • 16,587
  • 9
  • 52
  • 67
  • Thank you! btw, i removed the if condition since because it giving a warning that no such selector has been implemented and it works fine. – user1938695 Nov 23 '13 at 23:03
  • 1
    In Interface Builder you can simply disable the controller attribute `Under Top Bars` in the "Extend Edges" section. – Florian Mielke Dec 09 '13 at 10:12