ios pass values during a segue to another view

后端 未结 5 756
暗喜
暗喜 2020-12-24 12:15

Trying to do something I\'ve seen documented in a lot of places, but can\'t seem to manage. I\'m trying to pass data from one view to another during a segue.

Here\'s

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 13:10

    I think I had absolutely the same problem, so hope my solution will help you too. It should answer first part of your question, or at least will help some one else.

    First of all you can't assign passed values to properties with viewDidLoad method in the SecondViewController. Doing so, gives nil, as viewDidLoad is implemented before Segue.

    And I wouldn't recommend to use viewDidAppear, as as the values will be changed after the view is loaded, witch makes the change process be visually visible.

    So, the best option is to assign the values directly to the IBOutlet's. If you want to pass an array of strings, you can assign one array value witch you want to load first, and also pass all NSArray. This will allow your view to be loaded with the value already, and also you will have other values to work with.

    You could also call method and pass data.

提交回复
热议问题