Can't resize UIView in IB

IphoneXcodeInterface Builder

Iphone Problem Overview


Probably something simple, but I can't figure why I cannot resize a UIView in a xib in Interface Builder.

I created a new view XIB in xcode and in the size inspector, the width and height are disabled and grayed out to 320 by 460. This is strange since I can change the size for the other two views (associated with the other two tab bar items).

I am not sure if this has anything to do with but I recently updated the sdk to 3.

Thanks!

Iphone Solutions


Solution 1 - Iphone

In order to achieve that in XCode 4.6.3/5.0.2 you need to follow the screenshot below:

  1. Under 'File Inspector' -> untick Use Auto Layout
  2. Click on Attributes Selector & Choose Freeform for Size

This is needed when creating a headerView for a tableView

enter image description here

Solution 2 - Iphone

I think that you cannot edit the size while simulating any user interface elements such as the status bar in Interface Builder. You could try turning the simulated elements off if any are enabled. Not exactly sure why this is, so would appreciate feedback from anyone who knows why exactly this is - there must be a good reason.

Solution 3 - Iphone

The part that you are looking for is on the first Inspector panel (Command-1). Right at the top there is a section that is labeled Simulated User Interface Elements. By default the Status Bar is on. You need to make sure all three are set to None.

Solution 4 - Iphone

As at Xcode 4.2, iOS 5.0.1, the default simulated metrics include simulating the 'size' attribute of UIViewControllers to 'Inferred'

If you change this attribute to 'Freeform' then you are able to resize the UIView contained within the UIViewController while also simulating the status bar (or any other of the simulations for that matter)

Solution 5 - Iphone

Just go to the inspector, go to the first panel (or press command-1) and then change the fields marked Status Bar, Top Bar, and Bottom Bar to None under the section called "Simulated User Interface Elements". You may need to click the little triangle to make them visible.

Solution 6 - Iphone

Funny I have a similar problem. I've removed all views from the xib file and re-added a view. Set the status bar to being "unspecified" so that the status bar is not accommodated for. The view, when added, get created with x=0, y=0, w=320 h=460 instead of (0,0,320,480) as I would have expected. After changing the height to 480 and connecting it to file's owner and changing the color to make it distinctive in relation to the background. I fount that there was a white band between the top of the screen and the view. I augmented my code with:

#define RECTLOG(rect)    (NSLog(@""  #rect @" x:%f y:%f w:%f h:%f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height ));

within viewDidLoad

  • (void)viewDidLoad { [super viewDidLoad]; RECTLOG(self.view.frame); }
Turns out that the view is as it's loaded from IB is actually (0, 20, 320, 480) As a work around I reset the view's frame with self.view.frame = CGRectMake(0, 0, 320, 480);

I'm using IB 3.2.5

I'd love to know of a little fix for this one.

Solution 7 - Iphone

I've noticed that the UIView automatically created when creating the xib file cannot be resized from the sizing panel or the edge handles.

All I did was to add another UIView and dragged everything from my old UIView to the new one then deleted the old one.

It solved the problem for me but yes, I think there is an underlying issue with the interface builder for Apple to solve (somebody correct me if I'm wrong).

I'm Using XCode 4 integrated Interface builder.

Solution 8 - Iphone

I sorted it out in a different way...

open your xib with your favourite text editor and edit this line

        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CompassViewController">

CompassViewController is your class name you are trying to link your nib/xib with.

Just edit your class name with the correct class name and you are done ;)

Solution 9 - Iphone

enter image description hereIn storyboard select the UIVIew and go to the attributes inspector change the UIVIew size to "FreeForm" instead of "Inferred"

Solution 10 - Iphone

In Xcode 13

Storyboard -> Attribute inspector -> Size -> Freeform

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAyradView Question on Stackoverflow
Solution 1 - IphoneHoumanView Answer on Stackoverflow
Solution 2 - IphoneteabotView Answer on Stackoverflow
Solution 3 - IphoneThomas MonView Answer on Stackoverflow
Solution 4 - IphonelolView Answer on Stackoverflow
Solution 5 - IphonedavecomView Answer on Stackoverflow
Solution 6 - IphonecramheadView Answer on Stackoverflow
Solution 7 - IphonePowerAktarView Answer on Stackoverflow
Solution 8 - Iphonejeet.chanchawatView Answer on Stackoverflow
Solution 9 - IphoneJane.AbrahamView Answer on Stackoverflow
Solution 10 - IphoneAbdurakhmonView Answer on Stackoverflow