のテキストフィールドに値を渡す:第2のビューは、ユーザーが行を選択することができるテーブルビューである第一のビューを、空のテキストフィールドがあります。行をタッチすると、最初のビューのテキストフィールドに値を設定するアクションがあります。残念なことに私が最初のビューフィールドに戻ると、フィールドは設定されません。私はナビゲーションコントローラを持つ2つのビュー有する第一のビュー
これは私のコードです:
FirtViewController.h
@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
FirstViewController.m
#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];
}
SecondViewController.h
@class FirstViewController;
@interface ListaViewController : UIViewController
<UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate>
{
UITableView *table;
UISearchBar *search;
FirstViewController *controller;
}
@property (nonatomic, retain) FirstViewController *controller;
SeconViewController.m
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedRow = [tableData objectAtIndex:indexPath.row];
controller.selectedRow = selectedRow;
[self.navigationController popViewControllerAnimated:YES];
}
どこFirstViewControllerでご提示ください。SecondViewControllerをロードします。これで、SecondViewControllerをFirstにリンクする必要があります。 – Walter
上記を参照してください、私はその要求を入れます – Maurizio