1

任何人都可以确认这[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];将使您的应用程序被 Apple 拒绝。

有没有好的替代品?

4

4 回答 4

4

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientation] 是一个私有API,你可以发现签名是只读的(见这里)。

如果要将设备方向设置为纵向或其他模式,则应覆盖 shouldAutorotateToInterfaceOrientation:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIDeviceOrientationPortrait);
}
于 2010-03-05T10:51:29.360 回答
1

是的,你会被拒绝

您可以更改框架并对关键窗口应用转换,并更改状态栏方向(这是公共的)以模拟更改方向。

于 2010-03-05T13:30:51.657 回答
0

你可以试试这段代码。它在我的应用程序上完美运行

UIApplication* application = [UIApplication sharedApplication];
if (application.statusBarOrientation != UIInterfaceOrientationPortrait)
{
    AppDelegate* app = [[UIApplication sharedApplication] delegate];
    UIViewController *c = [[UIViewController alloc]init];
    [app.viewController presentModalViewController:c animated:NO];
    [app.viewController dismissModalViewControllerAnimated:NO];
    [c release];
}

其中 app.viewController 是应用程序的 rootViewController

于 2012-02-20T02:23:56.857 回答
0

您可以在应用程序列表中添加 UIInterfaceOrientation

于 2010-03-05T13:24:22.053 回答