Pregunta

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......?

¿Fue útil?

Solución

Change this code to the following:

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

And add the following:

- (BOOL) shouldAutorotate
{
    return YES;
}

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top