且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

意外地在 prepareForSegue 中发现了 nil IBOutlet

更新时间:2023-02-18 18:13:48

您不能在 prepareForSegue 中访问 DetailViewControllerIBOutlets,因为它们是尚未连接.

You cannot access IBOutlets of DetailViewController in prepareForSegue because they are not connected yet.

正如评论中提到的,在 DetailViewController 中创建一个 String 属性,在 prepareForSegue 中设置它并设置 text DetailViewControllerviewDidLoadviewWillAppear 中标签的属性.

As mentioned in the comments create a String property in DetailViewController, set it in prepareForSegue and set the text property of the label in viewDidLoad or viewWillAppear of DetailViewController.