Question

I have already completed my app in portrait orientation for iPhone and iPad, Now i need this same for the landscape orientation , I was used only xib's for both iPhone & iPad .and some UI are created in programatically. Just now i was Use this code:

-(NSUInteger)supportedInterfaceOrientations
{
    // return your mask here e.g.:
    if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
        return UIInterfaceOrientationMaskPortrait;
    else
        return UIInterfaceOrientationMaskLandscape;
}

but it does not work properly, so can anyone help me......?

Was it helpful?

Solution

Change this code to the following:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;  
}

And add the following:

- (BOOL) shouldAutorotate
{
    return YES;
}

OTHER TIPS

Finally i done that , now am using this code;

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { // NSLog(@"Landscape left");

} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    NSLog(@"Landscape right");

} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
  //  NSLog(@"Portrait");

} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
   // NSLog(@"Upside down");
}

} It was working good for all orientation , Thanq all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top