0

Why can't I drag a UISearchBar into a UINavigationBar in my Storyboard? I can drag in the UISearchBar but I can't add it as a subview. I've seen plenty of posts where people have done this. What am I doing wrong?

A Tyshka
  • 3,830
  • 7
  • 24
  • 46

1 Answers1

0

You can do this by first adding a UIView to your navigationbar and then add the searchbar, as previously answered here. Good Luck.

example

Community
  • 1
  • 1
JingJingTao
  • 1,760
  • 17
  • 28
  • Using that configuration I can't get the search bar to span across the top. – A Tyshka Jul 21 '16 at 14:32
  • Do you mean you can't make the searchbar the same width or height as the navigationbar? – JingJingTao Jul 21 '16 at 14:47
  • No I mean setting It up as a navigation item doesn't let me make my necessary auto layout constraints – A Tyshka Jul 21 '16 at 15:06
  • The best I can suggest is to set the 'titleView' of your navigationitem to your searchbar, http://stackoverflow.com/questions/5095477/uisearchbar-in-navigationbar, if you go with this approach you should programmatically create your searchbar. If you give me an image of what you're trying to achieve, I can try help you more. – JingJingTao Jul 21 '16 at 15:59