![]() ![]() Here, we can set the values we want to pass. A UIStoryboardSegue object is passed in when this method is called, and it contains a reference to our destination view controller. If we're using storyboard, our first view controller can override prepareForSegue, which is exactly what it's there for. The most common scenario asked about on Stack Overflow in my experience is the simple passing information from one view controller to the next. So, let's go through some of these scenarios. To suggest there is one simple catch-all solution to every scenario is a little naïve. We will explore how you can create a view controller in code and the storyboard - and present it in your app. You can find that project on github (link).Your question is very broad. Using multiple view controllers is an essential aspect of iOS development. The child view controllers are linked using embed segues, and the parent view controller wires up 2-way links with each view controller in the prepareForSegue method. I have a sample project on Github that uses a parent view controller to host 2 different table views as children. If the view controllers are linked via a storyboard segue, the time to set up the links is in the prepareFor Segue method. In fact, you can set up an active one-way or 2-way channel between different view controllers. As I mentioned in reply, it's also possible to send messages back from the destination to the source. Nhrif's answer lets you send information directly from the source to the destination VC. The data singleton I outlined in my first answer is really more about sharing and saving global state than about communicating directly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |