Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
实例化eViewController(标识符:创建者:)&x27;仅在iOS 13.0或更新版本中可用_Ios_Swift_Xcode - Fatal编程技术网

实例化eViewController(标识符:创建者:)&x27;仅在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) {

我收到此错误-InstanceEviewController(标识符:creator:)“仅在iOS 13.0或更高版本中可用

为了解决这个问题,我必须使用如下条件:

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)
    }