mnort9
mnort9

Reputation: 1820

ViewDidAppear and textFiedlDidEndEditing control flow

I have a push segue from a UITableViewController to another UITableViewController. An object is passed to the second VC via prepareForSegue. A UITextfield exists in the second VC to edit that object. The object is modified in the second VC's textFiedlDidEndEditing delegate method. Rather than creating a delegate method, I simply placed [self.tableView reloadData] in the first VC's viewDidAppear method to update the table which displays the object.

When a user navigates back to the first VC, I need to be sure that viewDidAppear in the first VC will be called only after the second VC's textFiedlDidEndEditing has completed and set the new object. It seems to be working this way, but it this because of chance or because viewDidAppear is only called after the previous VC's method's have implemented?

Upvotes: 0

Views: 162

Answers (2)

jackslash
jackslash

Reputation: 8570

viewDidAppear will be called when your first view has re-appeared on the screen. I assume you are programmatically popping the second view controller or using the unwind segue. If this is the case then call

[textField resignFirstResponder];

in your second VC.

Upvotes: 2

mnort9
mnort9

Reputation: 1820

In the textfield's VC, I had to place the below code to ensure textFieldDidEndEditing gets called before any other VC's viewWillAppear method.

[self.view.window endEditing: YES];

Upvotes: 1

Related Questions