문제

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

도움이 되었습니까?

해결책

Change this code to the following:

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

And add the following:

- (BOOL) shouldAutorotate
{
    return YES;
}

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top