gpt4 book ai didi

ios - 如何制作一个 iOS app Landscape ONLY

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:11:00 26 4
gpt4 key购买 nike

看起来很简单,对吧?转到目标的摘要选项卡并将“支持的界面方向”设置为仅横向右。您可能会认为这意味着该应用程序只能是横向的。但是没有。

例如,在运行 5.1 的设备上,如果您打开应用程序并将手机保持在正确的横向正确位置,您将看到 View 逆时针旋转 90 度,就好像它认为它应该处于纵向模式一样,除非您添加这样的内容:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

但这只适用于一个 View Controller ,谁知道它是否适用于所有操作系统版本。

那么如何只制作一个应用风景?我是否必须将该代码添加到应用程序中的每个 View Controller ?我不需要任何轮换。我所有的 View 都是在 Landscape 中设计的。我只希望该应用程序以横向右模式打开并保持这种状态。我想支持 iOS 5 及更高版本。

最佳答案

引入了新方法,您必须与旧方法一起实现,如下所示

-(BOOL)shouldAutorotate
{
return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}

关于ios - 如何制作一个 iOS app Landscape ONLY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15552532/

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