gpt4 book ai didi

ios - segue 如何创建目标 ViewController?

转载 作者:行者123 更新时间:2023-12-01 18:28:56 24 4
gpt4 key购买 nike

正如问题所暗示的那样:segue 如何创建目标 Controller ?具体来说,调用哪个方法?当 segue 创建他时,我想从 nib 初始化另一个 ViewController。我该如何做到这一点?

非常感谢

最佳答案

简短回答:initWithCoder:叫做。

更长的答案(from apple's docs on UIViewController ):

If your app uses a storyboard to define a view controller and its associated views, your app never initializes objects of that class directly. Instead, view controllers are either instantiated by the storyboard—either automatically by iOS when a segue is triggered or programmatically when your app calls the storyboard object’s instantiateViewControllerWithIdentifier: method. When instantiating a view controller from a storyboard, iOS initializes the new view controller by calling its initWithCoder: method instead. iOS automatically sets the nibName property to a nib file stored inside the storyboard.

关于ios - segue 如何创建目标 ViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10607872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com