Group Group Group Group Group Group Group Group Group

Chapter 37: UISearchBar Auto Layout Constraints

I’m trying to set the position of the UISearchBar within the view, but Xcode doesn’t let me set any auto constraints. The image below is what I see when I try to set auto constraints on the UISearchBar. If it’s helpful, I also included my view hierarchy. Any suggestions?

image

I have exactly the same issue. Posted this question on this forum yesterday. I didn’t see it was asked before.

@jvantoor I was able to solve it. Go to the Size Inspector for the search bar and make sure the
Layout property in the View section is set to Automatic and not Translates Mask Into Constraints. Once you do this you should be able to set Auto Layout constraints.

image

Hi @clarkesm, thank you for sharing your solution and glad you were able to solve it!