Re: How to prevent Segue with modal form-sheet and AutoLayout from resizing my view?
Re: How to prevent Segue with modal form-sheet and AutoLayout from resizing my view?
- Subject: Re: How to prevent Segue with modal form-sheet and AutoLayout from resizing my view?
- From: Michael Crawford <email@hidden>
- Date: Sat, 22 Sep 2012 15:25:05 -0400
This code was being called out of the -viewDidLoad context of the main view. By calling it asynchronously using GCD instead of performing the segue directly, the problem goes away. I'm not sure I would call this a solution. It feels more like a work-around, as I suspect the root cause is some sort of race condition, but it does work.
-Michael
On Sep 21, 2012, at 7:31 PM, Michael Crawford wrote:
> This problem is kind of tough to describe without pictures. Thus, there will be links to graphical images to help you understand my dilemma.
>
> So, I'm trying to display a modal form-sheet over the app's main view using Storyboards and a segue. I'm using Xcode 4.5 with iOS 6 to implement an iPad application. I'm also using AutoLayout. I already have a version of this code working on iOS 5.1 with springs and struts but I want to make the conversion to AutoLayout as I add support for iOS 6. Don't ask why; stay focused on the issue at hand, please.
>
> This is what I'm trying to display.
>
> https://dl.dropbox.com/u/4920112/1.PNG
> https://dl.dropbox.com/u/4920112/2.PNG
> https://dl.dropbox.com/u/4920112/3.PNG
>
> When I activate the segue and try to display the modal form, the form automatically resizes to cover the lower-left portion of the iPad view. In the console there are no exceptions due to conflicting constraints. There is also no reported ambiguity among the constraints in question.
>
> This is what I'm actually getting.
>
> https://dl.dropbox.com/u/4920112/4.png
>
> I added a few breakpoints to execute "po self.view" so I could see how the view was configured at the following points in the code:
>
> 1) Start of -viewDidLoad
> 2) Context of -viewDidLoad after executing self.view.autoresizingMask = UIViewAutoresizingNone;
> 3) Start of -viewDidAppear
>
> Here is the output from the console as a result of these three breakpoints:
>
> 1) (UIView *) $0 = 0x1dd969b0 <UIView: 0x1dd969b0; frame = (0 0; 540 620); autoresize = RM+BM; autoresizesSubviews = NO; layer = <CALayer: 0x1dd96aa0>>
>
> 2) (UIView *) $1 = 0x1dd969b0 <UIView: 0x1dd969b0; frame = (0 0; 540 620); autoresizesSubviews = NO; layer = <CALayer: 0x1dd96aa0>>
>
> The change from 540x620 to 1024x748 is the problem.
>
> 3) (UIView *) $2 = 0x1dd969b0 <UIView: 0x1dd969b0; frame = (0 0; 1024 748); clipsToBounds = YES; autoresize = W+H; autoresizesSubviews = NO; layer = <CALayer: 0x1dd96aa0>>
>
> This seems to tell me that the auto-resizing mask is successfully cleared but then re-instated between the call to -viewDidLoad and -viewDidAppear. Of course, I'm assuming this is the issue. I cannot assign a constraint to the main view itself in order to pin width and height. When I select the view, IB grays out the option.
>
> Anyone further along on the AutoLayout curve who can give me some suggestions as to how to prevent my form from being resized once it is loaded?
>
> -Michael
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden