ios - UISearchController searchBar frame only resizes on first click -


i have implemented uisearchcontroller in regular uiviewcontroller, , have kind of weird issue.

i have uiview adapted size want uisearchbar take. on first launch of view, add uisearchbar subview uiview. when launch it, uisearchbar doesn't take size of parent uiview -- takes width of whole screen.

enter image description here

as can see, overlaps button on right.

but once click on search bar , cancel it, resizes exact size want.

enter image description here

what issue here? i've tried adding autolayout constraints searchbar parent view doesn't seem change anything. doesn't [uiview addsubview:] handle this?

uisearchcontroller's view behaviour weird indeed, there simple workaround.

  • use additional container view
  • put uisearchcontroller's view inside
  • set uisearchcontroller's view autoresizing mask uiviewautoresizingflexiblewidth | uiviewautoresizingflexibleheight
  • set uisearchcontroller's frame container's view bounds

at point uisearchcontroller.view won't resize beyond container.bounds.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -