Reputation: 2324
I'd like to resize my app components when device is turned into left or right side - when it keep horizontal position
I'm checking device rotation in willRotateToInterfaceOrientation
event and then I have to change width of searchBar and tableView. How should I do it? I tried some variants with components .frame
and with CGRect
, nothing works.
Update: it can be done without any code. View my answer below
Upvotes: 0
Views: 899
Reputation: 2324
I found the way to do I need So, the task is that components will be resized in width when device turns horizontally.
1) Select items must be resized
2) Select "Leading Space to SuperView"
3) Without unselection, select "Add missing Constraints"
That's it. Now they will be resized correctly
Upvotes: 0
Reputation: 817
If you laid out your elements in Interface Builder then you can just add an outlet to the width constraint of your search bar. Then, change the constraint's constant
property to change the bar's width.
Upvotes: 1