ios - 如何将初始值传递给分割 View Controller 的详细信息?

标签 ios swift storyboard uikit

假设我有一个分割 View Controller : 1.主视图 Controller :内部有 View Controller 的导航 Controller ,其中嵌入了 TableView Controller 2. 详细 View Controller 。它取决于应传递给它的某些值(否则它将无法正常工作,应用程序将崩溃)

基本上,详细 View Controller 需要额外的初始化步骤,并且应该向其传递一些值,否则应用程序将崩溃。现在我知道如何在单击 TableView 行时传递此值,但问题是:如何第一次执行此初始化?我必须这样做,否则分割 View Controller 已经使用关联的详细 View Controller 进行了初始化,如果未传递此值,则会崩溃。是否有任何回调可以监听以传递该值?

最佳答案

Let say you have 2 View Controllers:

  1. ListViewController which has a list of your data

  2. DetailViewController which display the details of the data that you tapped from first ViewController

So if you want to pass your data and set it to your ViewController's components, you can declare some variables to store those data and then you can set those data to your components in override func viewDidLoad(){}

I hope this could answer your question and help.

关于ios - 如何将初始值传递给分割 View Controller 的详细信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58191701/

相关文章:

iphone - Objective-C 中的内存管理问题

swift - SKAction 按键改变 Sprite 行为

ios - 静态单元格 : Content does not appear

macos - OS X Storyboard : using "show" segue without allowing duplicate new windows to show?

ios - Alamofire 的 Swift 扩展方法返回 SwiftyJSON 结果

ios - 接收器类型 'FBSDKError'(又名 'enum FBSDKError')不是 Objective-C 类

swift - 如何处理 Swift 中一个键的两种可能类型的解码?

swift - DJI Bridge App 教程 Swift 无视频流 - Phantom 4 Pro

ios - 如何使用 segue 维护 UITabBar

ios - 在我的应用程序中使用自定义 UICollectionViewCell 时如何停止内存警告