Can't resize UIView in IB

2019-01-30 00:25发布

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!

8条回答
祖国的老花朵
2楼-- · 2019-01-30 00:40

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.

查看更多
在下西门庆
3楼-- · 2019-01-30 00:42

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.

查看更多
一夜七次
4楼-- · 2019-01-30 00:48

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.

查看更多
Lonely孤独者°
5楼-- · 2019-01-30 00:54

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.

查看更多
冷血范
6楼-- · 2019-01-30 00:56

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

查看更多
贪生不怕死
7楼-- · 2019-01-30 01:01

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.

查看更多
登录 后发表回答