iOS 5.1 shouldAutorotateToInterfaceOrientation: called but didRotateFromInterfaceOrientation: is not on first load

StackOverflow https://stackoverflow.com/questions/15207012

  •  18-03-2022
  •  | 
  •  

سؤال

So it looks like the first time I push a UIVIewController to my UINavigationController stack this method is called:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

But this method is not:

-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

Now if I rotate the device after the UIViewContoller is loaded then both of these are fired as expected.

Why is didRotateFromInterfaceOrientation not being called when my controller loads?

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

المحلول

From UIViewController Class Reference:

didRotateFromInterfaceOrientation:

Sent to the view controller after the user interface rotates.

didRotateFromInterfaceOrientation is not being called during load because there was no user interface rotation.

shouldAutorotateToInterfaceOrientation is called before every rotation. I am not sure why it's called during load. I think it could be a matter of some performance optimalization hint used by UINavigationViewController.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top