possen
possen

Reputation: 9266

When dismissing a fullscreen modal the viewWillLayoutSubviews method does not get called

I am trying to track down a problem where the viewWillLayoutSubviews (and viewDidLayoutSubviews) method do not get called after dismising a controller displayed using -

[self presentModalViewController:controller animated:YES];

and dismissing with

[self dismissModalViewControllerAnimated:YES];. 

This view controller is displayed on top of a UISplitViewController as the result of a button being pressed in the detail area. When I rotate the device, without the modal up, I do get the viewWillLayoutSubviews callback. However, the problem is, when I rotate during the presentation of the model, it does not update the views correctly and recalculate the view bounds after dismissing it. According to the IOS 5 release notes I should get a viewDidLayoutSubviews after dismissing the modal view controller.

For comparison, I created a bare bones app with none of my other code in it and it works as documented, it will call viewWillLayoutSubviews after the modal is dismissed.

I have been going over and over my real app code and can't find anything wrong. I am looking for suggestions for things to do help figure this out. Why would the callback work when rotating but not work when the modal is dismissed? Could it be something with my view hierarchy?

Thanks for any help!

Upvotes: 1

Views: 1964

Answers (1)

Jason Kulatunga
Jason Kulatunga

Reputation: 5893

Try using the delegate method viewWillAppear instead of viewWillLayoutSubviews. The WillLayoutSubviews is only called when the view's bounds change (which happens when you rotate the device).

Upvotes: 1

Related Questions