使用instantiateViewControllerWithIdentifier和performseguewithidentifier有什么区别? [英] What is the difference between using instantiateViewControllerWithIdentifier and performseguewithidentifier?

查看:92
本文介绍了使用instantiateViewControllerWithIdentifier和performseguewithidentifier有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两种方法都允许我提供一个新的视图控制器(一个通过调用presentviewcontroller),所以我不明白两者之间的区别以及何时应该使用它们。

Both methods allow me to present a new view controller (one by calling presentviewcontroller), so I don't understand the difference between the two and when I should use them.

推荐答案

他们都参考故事板相关的标识符。主要区别是一个( performSegueWithIdentifer )基于segue的结尾(segue指向的地方)实例化一个对象,而另一个( instantiateViewControllerWithIdentifier )基于VC的标识符(而不是segue)实例化一个唯一的VC。

They both reference storyboard related identifiers. The main difference is one (performSegueWithIdentifer) instantiates an object based on a segue's end (where the segue points to), while the other (instantiateViewControllerWithIdentifier) instantiates a unique VC based on the VC's identifier (not the segue).

你可以在不同的地方有多个具有相同标识符的segue故事板,而故事板中的VC不能具有相同的标识符。

You can have multiple segue's with the same identifier in different places in the storyboard, while VC's in a storyboard cannot have the same identifier.

这篇关于使用instantiateViewControllerWithIdentifier和performseguewithidentifier有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆