gpt4 book ai didi

ios - 横向到纵向在 ipad 中不起作用?

转载 作者:行者123 更新时间:2023-11-29 12:54:29 25 4
gpt4 key购买 nike

我使用了以下方法来改变方向,但它没有调用。为什么会这样?

-(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;
}
}

最佳答案

- (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)

{


}

关于ios - 横向到纵向在 ipad 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21494684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com