gpt4 book ai didi

iphone - ipad 应用程序不适用于横向模式

转载 作者:行者123 更新时间:2023-12-03 21:05:40 24 4
gpt4 key购买 nike

iPad 在纵向上运行良好,但在横向上运行不佳,

我使用这个代码

- (BOOL) isPad{ 
#ifdef UI_USER_INTERFACE_IDIOM
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
#else
return NO;
#endif
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([self isPad]) {

return YES;
}
else
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}

}


- (BOOL)isPadLandscape
{

return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
&& (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight
|| self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft));

}

- (BOOL)isPadPortrait
{

return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad
&& (self.interfaceOrientation == UIInterfaceOrientationPortrait
|| self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown));
}




- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if ([self isPadPortrait])
{
[imageView setFrame:CGRectMake(0, -50, 768, 1024)];
}
else if ([self isPadLandscape])
{
[imageView setFrame:CGRectMake(0, 0, 1024, 768)];
}
}

我尝试在调试期间调用 -(BOOL)isPadLandscape 方法,但该方法未调用,

可能出了什么问题?

最佳答案

不要忘记在 Info.plist 文件中设置属性支持的界面方向 (iPad) 以获取适当的支持位置。

或者试试这个:

- (BOOL) isPad{ 
return [[UIDevice currentDevice].model hasPrefix:@"iPad"];
}

关于iphone - ipad 应用程序不适用于横向模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7283183/

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