0

In my app I'm switching between UIViewController using Navigation Controller and the Action Segue "Show". But for example if I write something in a UITextView and I return in that UIViewController the text is deleted. How I can keep the information ? Like in the UITabBarController.

2 Answers2

0

You can create uiviewcontroller objects in app delegate and use that objects for swapping between view controllers. In current scenario, whenever you load same view controller again, it is created as fresh object so UITextView is initialized again, so text you entered will not be saved.

Or you can save value of UITextView in global variable or NSUserDefaults on viewwilldisappear() and initialize again in viewwillappear()

Shefali Soni
  • 1,234
  • 14
  • 26
0

U can use restoration ID in the IB for that particular UITextView.

enter image description here

KP_G
  • 460
  • 4
  • 15