Shishir.bobby
Shishir.bobby

Reputation: 10984

shouldAutorotateToInterfaceOrientation not working

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}

are not working, and i dont hv any idea,why. When i try debugging, and rotate the device, these method not called.

I just want to detect the orientation if orientation = landscape perform action a else perform action b

Many Thanks

Upvotes: 0

Views: 1708

Answers (1)

Mike
Mike

Reputation: 121

I agree with Clafou, how you setup your app can mess with rotation.

Add this and see if it fires:

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    BOOL isPortraitOrientation;

    if ((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)){

        isPortraitOrientation = YES;

    } else if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight)){

        isPortraitOrientation = NO;

    }
} 

Upvotes: 2

Related Questions