user317033
user317033

Reputation:

How to resize view in XIB?

I'm trying to follow these instructions with Xcode 4, but am unable to resize the xib. Does anyone know how? ( The width and height cannot be clicked upon ) Also there is no UITableViewController so I just used UIViewController.

EDIT - My goal is actually not to use the popover controller, I simply want to create a modal login dialog following the example here: How to resize a UIModalPresentationFormSheet? and am trying to make the view controller 300x400

A popover controller has to have a view controller inside of it. So we need to create a new view controller. Go to File > New File > Cocoa Touch Classes > UIViewController > UITableViewController subclass >> With XIB for UI >> Targeted for iPad. Name it OptionsViewController. Drag your viewcontroller.h and viewcontroller.m files into the classes group and the new XIB into the resources group.

Open the XIB and go to the Size inspector. Change the width and height properties to 250 and 300. Save your file and close interface builder.

Upvotes: 27

Views: 29965

Answers (3)

shoaib sheikh
shoaib sheikh

Reputation: 61

In swift 4.2 interface builder won't let you change the size

click on the view and open the attribute inspector and change top, bottom bar to none and size to freeform. Now you are good to go for the change in size.

enter image description here

Upvotes: 6

Adam
Adam

Reputation: 33126

It appears that in Xcode 4.5+, just to be annoying: Apple changed this again.

Instead, you now have to:

  1. select the viewcontroler
  2. select the "size" dropdown
  3. set it to "Freeform"

...which removes their "block" on editing the size fields.

(this is pretty close to how I expected it to work in the first place, but I have to say it's not easy to find - you have to edit a different value on a different screen (with no help from Apple), in order to un-break the edit field on the correct screen. Not good design!)

Upvotes: 47

zpasternack
zpasternack

Reputation: 17898

Interface Builder (and the IB equivalent in Xcode 4) won't let you change the size (or autosizing attributes) of a top-level view when any Simulated User Interface Elements are enabled.

Select your view, and in the View Attributes inspector set Status Bar, Top Bar, and Bottom Bar to Unspecified. You should then be able to change the size.

Upvotes: 35

Related Questions