MattyG
MattyG

Reputation: 8497

self.interfaceOrientation causing shouldAutorotateToInterfaceOrientation to be called on iOS 4.x

When I test my single view app under 4.x in the simulator or device, upon startup the main UIViewController's shouldAutorotateToInterfaceOrientation: method is called precisely 3046 times (on device) or 23777 times (on simulator) and then crashes. ...updated...

UPDATE: Inside the method I have UIInterfaceOrientation currentOrientation = self.interfaceOrientation;

This seems to be the culprit, it causes shouldAutorotateToInterfaceOrientation: to be called again, therefore putting it into an infinite loop until it crashes. Anyone know why? It doesn't do this in iOS 5+

Upvotes: 1

Views: 432

Answers (1)

waheeda
waheeda

Reputation: 1097

if you need to do any processing on Orientation change event, use this method instead,

 - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
 {
    [self HandleOrientationChange:toInterfaceOrientation];
 }

 -(void) HandleOrientationChange:(UIInterfaceOrientation) orientation
  {}

Upvotes: 1

Related Questions