我在我的应用程序中有两个视图:在主视图中有用户必须填写的输入字段和连接到第二个视图的按钮。在第二个视图中有一个表视图,当用户选择一行时自动返回到主视图。 我的问题是,当您返回到主视图时,文本字段的值将被清除。 任何解决方案? 谢谢。给textfield赋值firstview take secondview
二视野头
@class MainViewController;
@interface ListaViewController : UIViewController
<UITableViewDataSource, UITableViewDelegate, UISearchBarDelegate>
{
UITableView *table;
UISearchBar *search;
MainViewController *child;
}
@property (nonatomic, retain) IBOutlet UITableView *table;
@property (nonatomic, retain) IBOutlet UISearchBar *search;
@property (nonatomic, retain) MainViewController *child;
- (IBAction)switchBack:(id)sender;
二View实现:
-(IBAction)switchBack:(id)sender
{
child.selectedCountry = selectedCountry;
child.codiceComune = codiceComune;
[self.navigationController popViewControllerAnimated:YES];
}
首先查看:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
cityField.text = selectedCountry;
}
这不行!
中写的那样你正在重新创建你的viewcontroller。这是重新创建您的文本字段。你需要切换回原来的viewController而不是重新创建它。 – ader 2011-12-23 12:06:58