【发布时间】:2012-07-13 00:18:46
【问题描述】:
我正在编写一个有 2 个视图的程序。从主视图,即 FirstView,我通过以下方式移动到第二个视图:
-(IBAction)switchToSecondView:(id)sender{
SecondViewController *screen=[[SecondViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:screen animated:YES];
[screen release];
}
在第二个视图中,我有一个按钮和一个标签。 SecondView 是一个简单的活动,其 Label 的值从 0 开始。每次单击一个按钮都会导致 Label 增加 1。所以我对 SecondView 所做的是单击按钮将 Label 的新值设置为 5。
然后我通过调用返回到 FirstView:
[self dismissModalViewControllerAnimated:YES];
那么结束,我又回到了SecondView,但是Label的值还是5,这说明SecondView的状态不明确。
有没有办法在离开时清除所有 Second View 的状态?谢谢
【问题讨论】:
-
您的第二个观点究竟是什么? UITextfields 等?
-
@nicktones:我刚刚在我的问题中添加了一些内容。