سؤال

I'm using Xcode 4.6.2, and am having trouble resizing my views.

For instance, I just created a new Storyboard, and dropped one regular UIView on top of another. I went to to change it's top, by grabbing the handle, and the whole top line became red, and would not move.

Now, I can force it to move by holding down the option key (or is it the command key), but I used to be able to resize views pretty easily it Xcode. I'm wondering, is Auto Layout causing me these headaches? Or is it some setting that I'm missing? I just want to resize my newly-dropped view, by dragging the handles, but can't.

هل كانت مفيدة؟

المحلول

Yes, I think it is autolayout. In building my views when I have seen the behavior you describe it is because I'm resizing a view that has fairly rigid constraints between its edges and other views. I usually get around it by first updating my constraints to something less restrictive (by deleting or lowering the priority) and then reviewing the constraints once I have resized it.

You may also have success unchecking the options in the When Resizing Views Apply Constraints To... menu. In the storyboard editor it is in buttons on the lower right and looks like two rectangles (windows) with one smaller than the other.

نصائح أخرى

The above mentioned solution didn't work for me.

What i did to resolve this issue was that i explicitly set the frame of the view in viewDidLoad.

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.frame = CGRectMake(0.0, 0.0, 280.0, 170.0);  // explicitly set your view's frame
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top