【发布时间】:2011-04-28 12:34:01
【问题描述】:
我有两个视图,每个视图都关联了一个 UIViewController 类。
在 view1(名为 RechercherViewController)中,我有一个简单的 UITextField,用户在其中输入内容,然后单击一个按钮,当单击此按钮时,用户被重定向到 view2(名为 StationsSurLaCarteViewController ) 我必须在 UILabel 中向他展示他在之前的视图中输入的内容。我的计划按我的意愿工作得很好,但是对于第一个 essai,我的意思是第一个值没有改变,尽管用户返回并更改了它,他总是(在 view2 的标签中)找到他第一次输入的内容。
所有声明都是正确的,这是我在 view1 按钮的 IBAction 中的代码:
RechercherViewController.m
-(IBAction)goToStationsSurLaCarteView {
TopStationAppDelegate *topStation=(TopStationAppDelegate *)[[UIApplication sharedApplication]delegate];
topStation.data=[typeCarburantTextField text];
stationsSurLaCarteViewController.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:stationsSurLaCarteViewController animated:YES];
}
在第二个视图中,此代码位于 viewDidLoad 中: StationsSurLaCarte.m:
- (void)viewDidLoad {
TopStationAppDelegate *topStation=(TopStationAppDelegate *)[[UIApplication sharedApplication]delegate];
[label setText:topStation.data];
[super viewDidLoad];
}
我不知道,但我怀疑我是否遗漏了某些必须释放才能始终保留用户输入的新值的内容。
【问题讨论】:
标签: ios uiviewcontroller