Note that there are some explanatory texts on larger screens.

plurals
  1. POPass a value to the text field of the first view
    text
    copied!<p>I have two views with navigation controller: first view, there are empty text fields while the second view is a table view where the user can select a row. At the touch of a row there is an action that sets a value to a text field of the first view. Unfortunately when I go back to the first view field is not set.</p> <p>This is my code:</p> <p>FirtViewController.h</p> <pre><code> @interface FirstViewController : UIViewController { UITextField *firstField; UITextField *secondField; } @property(nonatomic, retain) IBOutlet UITextField *firstField; @property(nonatomic, retain) IBOutlet UITextField *secondField; @property(copy) NSString *selectedRow; -(IBAction)showTable:(id)sender </code></pre> <p>FirstViewController.m</p> <pre><code> #import "FirstViewController.h" #import "AppDelegate.h" #import "SecondViewController.h" @implementation FirstViewController @synthesize ..... ............. -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.firstField.text = selectedRow; } -(IBAction)showTable:(id)sender { SecondViewController *controllerSecond = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; [self.navigationController pushViewController:controllerSecond animated:YES]; } </code></pre> <p>SecondViewController.h</p> <pre><code> @class FirstViewController; @interface ListaViewController : UIViewController &lt;UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate&gt; { UITableView *table; UISearchBar *search; FirstViewController *controller; } @property (nonatomic, retain) FirstViewController *controller; </code></pre> <p>SeconViewController.m</p> <pre><code> - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *selectedRow = [tableData objectAtIndex:indexPath.row]; controller.selectedRow = selectedRow; [self.navigationController popViewControllerAnimated:YES]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload