gpt4 book ai didi

iphone - shouldAutorotateToInterfaceOrientation 但没有任何反应

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

我们的应用被拒绝了,因为该应用没有以倒置的方向旋转。

所以我们有一个标签栏应用程序,将此代码添加到所有标签...

shouldAutorotateToInterfaceOrientation

没有意义,将此代码添加到 Appdelegate 没有帮助,我们做错了什么?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}

最佳答案

UITabbarcontroller 是 UIViewcontroller 的子类。要解决您的问题,只需为您的 UITabbarcontroller 实现子类化或添加一个类别:

@interface UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

@implementation UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end

如果你想让标签栏只旋转到纵向和上下颠倒,只需使用以下代码即可

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

关于iphone - shouldAutorotateToInterfaceOrientation 但没有任何反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7693517/

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