I’m just starting out in iOS app development,so if this question seems foolish please bear with me.
I’m creating a sample app where I have 2 view controllers.The first one has a full screen image,with a navigation bar and a camera roll button, which I use to pick a image from the galley when the app starts.Then I swipe to the second view controller where I enter some data like who clicked it,what camera was used etc in a text box.The second view controller has a navigation bar and a button Item in the navigation bar which I named back to return to the 1st view controller with the image.I have linked this button via the segue to the 1st view controller.Now with this setup everything is functional,but the only problem is when I load a image from the gallery and swipe to the second view to write the data,and then hit the back button to return to the first view, the image that I loaded from the gallery is no longer there and I’m presented with a blank screen.
So how can I make sure that I don’t loose the loaded image when I swipe back from the second view controller to the first one?
Thanks any help would be appreciated.
The problem is that you probably control dragged the button of the second view to the first view right? This doesn’t “move” to that viewcontroller, this “creates” a new viewcontroller of the first type, which is why its empty. If you want to return to the first view controller you have to add the action for the button. You can simply “dismissViewController” if the data in the second one dissapears. Or make a strong pointer from controller 1 to controller 2 so that you can dismiss but then present it again if you want the information to not dissapear. (without the strong pointer the VC is unloaded when you dismiss it)