Lijith Vipin
Lijith Vipin

Reputation: 1906

TextField is losing users' input when rotating

PROBLEM

When a user types into the TextField (landscape mode, or portrait) and rotates the phone the text is lost. Iam Using Different ViewContoller for landscape and portrait for same Page.

QUESTION

How can I prevent the loss of the text ?

Upvotes: 0

Views: 99

Answers (2)

Vaibhav Jhaveri
Vaibhav Jhaveri

Reputation: 1605

You can pass the TextField text from one controller to another using Delegates or NotificationCenter

Upvotes: 2

Vishnu gondlekar
Vishnu gondlekar

Reputation: 3956

If you are using different view controllers its obvious that textfield will lose its value as each of the view controller has its own textfield object. You can have a static variable in which in you can store textfield text in viewWillDisappear of each the the view controller. And in viewWillAppear of both view controllers you can set value from your static variable to text property of textfield.

Upvotes: 1

Related Questions