I have an iPhone app with a main view that has a UILabel
and a UIButton
. When the button is clicked, I display a second view. The second view has a text box and an OK
button.
I want the user to enter something in the second view's text box and then click the OK button; this should close the second view and apply the entered text to the UILabel
back on the first view.
How can I expose the contents of the text box on the second view, and how do I access this from the first view? Also, how can I get the OK button on the second view to close the view (i.e. navigate back to the first view)?
Update: Since I'm coming from the .NET world, I can describe how I would do this same task in .NET, and that might make it clearer what I'm trying to do. In a .NET application, I would create a form (with the text box and button), and then display it using ShowDialog
, which presents the form modally. I would add a public property to the form (called EnteredText
or something) which returns whatever is in the text box. When my calling code continues from the ShowDialog
call, I simply read the form's EnteredText property and use it however, then dispose of the form.
I'm trying to do basically the same thing with an iPhone app.