0

enter image description here enter image description here

I have a tableviewcontroller with a button, textfield, and a search bar display controller in the header view of the tableview.

When I click on the searchbar, then on either cancel or the background tableview(to dismiss it), the search bar will re size to cover the entire view it was in(over the button and text field).

In viewDidLoad I have

self.searchBar.translatesAutoresizingMaskIntoConstraints = YES;

http://i479.photobucket.com/albums/rr152/nebulouslove/photo.png

Any ideas please?

jgvb
  • 304
  • 5
  • 16

1 Answers1

1

Just add height and width constraints to the search bar and pin it to top, left, and right.

You can do that here:

here:

Mika
  • 5,807
  • 6
  • 38
  • 83
  • Can I add constraints in IB and how do I pin in IB? Under the size inspector tab for the search bar, I have the top middle red dot picked. So it seems to expand to the left, right, and down. – jgvb Feb 05 '14 at 20:09
  • I'm trying to find it! But I can't :( I have something that says...The selected views have no constraints. At build time explicit left, top, width, and height constraints will be generated for the view. – jgvb Feb 05 '14 at 20:23
  • You need to click on the search bar and then on the icon I show you in my picture. Then click on height, width, and the three red things on top. – Mika Feb 05 '14 at 20:25
  • THanks! brilliant I was wondering where the strut like feature went – jgvb Feb 05 '14 at 20:31
  • but now when I hit cancel I get errors :( Assertion failure in -[UITableView layoutSublayersOfLayer:] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super. – jgvb Feb 05 '14 at 20:42
  • Strange. Try putting the search bar in it's own view? If not I have no idea. Sorry. – Mika Feb 05 '14 at 20:48
  • A few other solutions here: http://stackoverflow.com/questions/19818998/searchdisplaycontroller-searchbar-overlapping-navigation-bar-and-resizing-itself – Mika Feb 05 '14 at 20:50