-1

In Storyboard, I have a UIToolbar on a UIViewController.

The UIBarButtonItems are:

Left Button / Flexible Button / Nutton 2 / Button 3 / Button 4

On App start the buttons are correctly spaced on the UIToolbar with Left button left-most and Button 2-4 aligned from the right-hand edge of the toolbar.

After a rotation the buttons have not moved so that, in rotating from Portrait to Landscape, there is a lot of space to the right of Button 4.

Am I missing a setting that will automate the relayout? Do I have to add something in the function viewWillTransitionToSize:withTransitionCoordinator ?

Carl
  • 2,896
  • 2
  • 32
  • 50
  • Is the toolbar itself configured to change width on rotation? What are its constraints? – matt Feb 19 '17 at 16:16
  • Good question! The toolbar is resized on rotation. It has constraints on left/right/top and a fixed height. – Carl Feb 19 '17 at 16:33

1 Answers1

0

The behavior you are hoping for is the normal behavior of a toolbar, as you can easily prove to yourself with a simple clean project containing nothing but a toolbar:

enter image description here

enter image description here

That is a totally nonstandard toolbar, in the sense that you're not supposed to put a toolbar in the middle of its superview like that. But it is pinned exactly as you describe your toolbar to be pinned, with exactly the contents you describe in your question, and it behaves exactly as expected.

Therefore I conclude that you must be doing something else that messes up the behavior of the toolbar, keeping it from doing what it normally does. But you have given no information about what that is, so that is as far as I can go.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Fair reply. Of course, if I could state what the none standard setting I had, there'd be nothing to post :) I'll try rebuilding the storyboard vc and see if xcode reproduces my issue. – Carl Feb 19 '17 at 17:23
  • In a fresh project I've confirmed the automatic relayout after a rotation is done automatically by iOS. For whatever reason, toolbars in my app are not handled this way. I will investigate further. – Carl Feb 20 '17 at 11:44