在view文件如何引用xVC、yVC
时间: 2023-05-20 20:02:46 浏览: 105
在view文件中,可以通过以下方式引用xVC、yVC:
1. 如果xVC、yVC是在同一个Storyboard中,可以使用Storyboard ID进行引用,例如:
```
let xVC = storyboard?.instantiateViewController(withIdentifier: "xVCID") as! xVC
let yVC = storyboard?.instantiateViewController(withIdentifier: "yVCID") as! yVC
```
2. 如果xVC、yVC是在不同的Storyboard中,可以使用Storyboard Name和ViewController ID进行引用,例如:
```
let xStoryboard = UIStoryboard(name: "xStoryboardName", bundle: nil)
let xVC = xStoryboard.instantiateViewController(withIdentifier: "xVCID") as! xVC
let yStoryboard = UIStoryboard(name: "yStoryboardName", bundle: nil)
let yVC = yStoryboard.instantiateViewController(withIdentifier: "yVCID") as! yVC
```
注意:在引用Storyboard时,需要确保Storyboard Name和ViewController ID的拼写和大小写都是正确的。
阅读全文