如何强制Swift iOS游戏应用程序在横向打开? (GameViewController)

时间:2017-06-18 23:19:48

标签: ios swift xcode ios-simulator

我正在使用Spritekit在iOS中创建游戏,我希望我的游戏只能横向进行。然而,每当我在模拟器中测试我的游戏时,无论我尝试什么,它总是以纵向方向加载。我已经在这个问题上阅读了很多堆栈溢出帖子,我尝试了以下但没有成功:

GameViewController

from bs4 import BeautifulSoup

import requests

header = {'User-agent' : 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5'}

url  = requests.get("http://www.jsugamecocksports.com/boxscore.aspx?path=baseball&id=4109", headers = header).text

soup = BeautifulSoup(url, 'html.parser')   
region = soup.find_all('div', {'id': 'inning-all'})
table = region.find('table', {'class': 'sidearm-table play-by-play'})

请注意我也尝试将Autorotate从true切换为false。这也不起作用。

Xcode项目文件

Xcode project file

的Info.plist

Info.plist

这些都没有效果

2 个答案:

答案 0 :(得分:2)

尝试添加此功能:

func navigationControllerSupportedInterfaceOrientations(_ navigationController: UINavigationController) -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.portrait
}

答案 1 :(得分:1)

使用UIInterfaceOrientationMask设置方向。

 private var orientations = UIInterfaceOrientationMask.landscapeLeft
    override var supportedInterfaceOrientations : UIInterfaceOrientationMask {
        get { return self.orientations }
        set { self.orientations = newValue }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    }