Ios 横向到纵向定向在ipad中不起作用?

Ios 横向到纵向定向在ipad中不起作用?,ios,ipad,uiinterfaceorientation,Ios,Ipad,Uiinterfaceorientation,我使用了以下方法来更改方向,但它不调用。为什么会这样 -(void)viewWillAppear:(BOOL)animated { if(self.interfaceOrientation==UIInterfaceOrientationPortrait||self.interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) { [self potraitFrame]; }

我使用了以下方法来更改方向,但它不调用。为什么会这样

-(void)viewWillAppear:(BOOL)animated
{
if(self.interfaceOrientation==UIInterfaceOrientationPortrait||self.interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)
        {
            [self potraitFrame];
        }
        else
        {
            [self landScapeFrame];
        }
}
//自动旋转法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    BOOL returnval=NO;

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        if(interfaceOrientation==UIInterfaceOrientationPortrait||interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)
        {
            [self potraitFrame];
        }
        else
        {
            [self landScapeFrame];
        }
        returnval = YES;
    }
    return returnval;
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        if(toInterfaceOrientation==UIInterfaceOrientationPortrait||toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)
        {
            [self potraitFrame];
        }
        else
        {
            [self landScapeFrame];
        }
    }
}
-(BOOL)shouldAutorotate
{
    return YES;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    //    UIInterfaceOrientation crntOrntatn = self.interfaceOrientation;
    //    return UIInterfaceOrientationIsLandscape(crntOrntatn) ? crntOrntatn : UIInterfaceOrientationLandscapeLeft;
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        return self.interfaceOrientation;
    }
}

-(NSUInteger)supportedInterfaceOrientations
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        return UIInterfaceOrientationMaskAll;   
    }
}

是否调用supportedInterfaceOrientations?是否将viewcontroller添加为子视图或直接从其他viewcontroller推送或显示?请确保已正确配置“Info.plist”@MichaelDautermann我做对了。支持的界面方向(iPad)UIInterfaceOrientation纵向UIInterfaceOrientation纵向UIInterfaceOrientation纵向UIInterfaceOrientation向上向下UIInterfaceOrientation和景观左侧UIInterfaceOrientationLandscapeRight@cjd不调用supportedInterfaceOreintations,而viewController被推送。WillAnimateRotationInterfaceOrientation不起作用吗?您使用故事板或XIB首先告诉我我使用的是XIB,但我没有在其上实现,我在代码本身中完成所有UI。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                     duration:(NSTimeInterval)duration
{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
    ||  toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
    Nslog(@"Landscape");
}
else
{

    Nslog(@"Potrait");

}

}

 this code it will be use full for rotation....and u can write in viewwillappear like this


  UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{


    //Do your stuff for landscap

} else if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)

{


}