0

I came across a strange problem, i'am in landscape and present a VC

SomeViewController * vc = [[SomeViewController alloc] init];
[self.navigationController presentViewController:vc animated:YES completion:^{

}];

in the viewWillAppear the frame is incorrectly in portrait and in viewDidAppear it is correctly in landscape

but when i put it inside a UINavigationController

SomeViewController * vc = [[SomeViewController alloc] init];
UINavigationController * nc = [[UINavigationController alloc] initWithRootViewController:vc];

[self.navigationController presentViewController:nc animated:YES completion:^{

}];

than in the viewWillAppear the frame is correctly landscape

Is this a bug? I'am i missing something? Why it is behaving like this?

Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179

1 Answers1

0

I think it is by design, see this answer A: View frame changes between viewWillAppear: and viewDidAppear:.

By viewDidAppear the frame geometry is correct since it is now on-screen and added to the view hierarchy but I would actually recommend doing it in viewDidLayoutSubviews since that will be called when rotating orientations as well.

Community
  • 1
  • 1
Korey Hinton
  • 2,532
  • 2
  • 25
  • 24