【发布时间】:2020-02-06 11:00:09
【问题描述】:
我使用的是 Xcode 11.1,我的部署目标是 iOS 10.0
我不能像以前那样实例化视图控制器。这是
中的代码func 应用程序(_ 应用程序:UIApplication, didFinishLaunchingWithOptions 启动选项: [UIApplication.LaunchOptionsKey : Any]?) -> Bool
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(identifier: "TabBarController")
我收到错误消息:
'instantiateViewController(identifier:creator:)' 仅适用于 iOS 13.0 或更新版本
如何在 Xcode 11.1 上以编程方式从情节提要中实例化视图控制器。还有什么办法吗?
【问题讨论】:
-
请查看您的
Deployment target。我认为它低于 13.0,所以你不能使用这种方法。 -
感谢@Mahendra。对于 13 以下的 iOS 版本,我通过将
identifier:更改为withIdentifier解决了这个问题