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.
as can see, overlaps button on right.
but once click on search bar , cancel it, resizes exact size want.
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
Post a Comment