0

I am reading (through O'Reilly Safari) the book Learning iPad Programming and there is a modal view with a toolbar and 2 buttons ("Cancel" and "Done") at the top.

My problem is that when I try to recreate that universal app, at the iPad simulator the toolbar doesn't use the whole window width:

enter image description here

There is a "flexible space" element between the buttons, but it seems not to affect the parent toolbar.

Can anybody please advise me how to stretch the toolbar and the textfield, maybe I need to set some property of it in Xcode 5?

enter image description here

UPDATE 2:

I've attached 2 new screenshots - don't see any "autoresizing" in Xcode 5:

enter image description here

enter image description here

I've submitted my question at Github too.

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416

1 Answers1

3

It Looks like your View doesn't resize to the complete width. I guess it does not have the Autoresizing Width attribute. You can set in in InterfaceBuilder of your xib in the size inspector.

size inspector xib

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
slecorne
  • 1,720
  • 1
  • 11
  • 14
  • Could you make the same screenshots (Attributes and Size inspector) without selecting toolbar but only View. – slecorne Oct 21 '13 at 11:08
  • I've updated my question with the requested screenshot (Xcode 5, View selected) - unfortunately do not see any Autosizing there. There is only Origin. – Alexander Farber Oct 21 '13 at 14:11
  • 1
    Ok, thanks. Try reducing the content hugging priority of the view to 1 and check the behavior. You may need also to add constraint to the toolbar and reduce hugging priority to allow it to grow. – slecorne Oct 21 '13 at 15:11
  • Adding constraints (as an iOS newbie I didn't know about them) has helped me, thanks. The book author has recommended them too: https://github.com/kirbyt/PhotoWheel/issues/3 What's a "hugging priority"? :-) – Alexander Farber Oct 21 '13 at 15:22
  • 1
    See this for quick explanation on hugging priority and compression resistance: http://stackoverflow.com/questions/15850417/cocoa-autolayout-content-hugging-vs-content-compression-resistance-priority – slecorne Oct 21 '13 at 15:38