实例化eViewController(标识符:创建者:)&x27;仅在iOS 13.0或更新版本中可用
我收到此错误-InstanceEviewController(标识符:creator:)“仅在iOS 13.0或更高版本中可用 为了解决这个问题,我必须使用如下条件:实例化eViewController(标识符:创建者:)&x27;仅在iOS 13.0或更新版本中可用,ios,swift,xcode,Ios,Swift,Xcode,我收到此错误-InstanceEviewController(标识符:creator:)“仅在iOS 13.0或更高版本中可用 为了解决这个问题,我必须使用如下条件: if #available(iOS 13.0, *) { } 但是在没有这个条件的情况下,如何解决这个问题呢 我的代码: func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if #available(iOS 13.0, *) {
}
但是在没有这个条件的情况下,如何解决这个问题呢
我的代码:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let vc = storyboard?.instantiateViewController(identifier: "CartViewController") as? CartViewController
vc?.bookNameToSend = bookName[indexPath.row]
vc?.bookImageToSend = bookImage[indexPath.row]
self.navigationController?.pushViewController(vc!, animated: true)
}
}
我认为解决这个问题的唯一方法是将project的最低目标版本更改为iOS 13或避免使用该特定方法,否则您将不得不使用if条件。在iOS 13中,苹果引入了这个新方法
InstanceDeviceController(标识符:creator:)
,这会造成混乱,但旧方法仍然存在
因此,请改用实例化ViewController(带标识符:)
let vc = storyboard?.instantiateViewController(withIdentifier: "CartViewController") as? CartViewController
在iOS 13中,参数名称为
标识符
,在iOS 13版本下,参数名称为带标识符
if #available(iOS 13.0, *) {
let vc = storyboard.instantiateViewController(identifier: "doctorProfileVC") as DrProfileViewController
self.navigationController?.pushViewController(vc, animated: true)
} else {
let vc = storyboard.instantiateViewController(withIdentifier: "storyboard.instantiateViewController") as! DrProfileViewController
self.navigationController?.pushViewController(vc, animated: true)
}