为什么要将AutorotateToInterfaceOrientation方法标记为不可用?

szu*_*rse 3 screen-orientation ios swift

我将此代码放到UIViewController子类中:

override func shouldAutorotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation) -> Bool {
    return true
}
Run Code Online (Sandbox Code Playgroud)

我得到这个编译时错误:

无法覆盖已标记为"不可用"的"shouldAutorotateToInterfaceOrientation"

有什么问题?我怎么能解决这个问题?

Boi*_*oid 8

shouldAutorotateToInterfaceOrientation 已弃用尝试使用 shouldAutorotate()