假设,在Xcode上的我的xiphone项目中,我有一个闪屏“a”,第一个视图“b”,第二个视图“c”,第二个视图上的“后退”按钮。现在我的任务是,当我的应用程序第一次启动时,将启动启动画面。然后会显示“b”。然后转到“c”。之后,我将再次启动应用程序,将显示视图“c”。如果我想看到视图“b”,我必须在视图“c”上按“后退”按钮。否则视图“b”将永远不会显示。
这是我的问题。 我怎么能解决这个问题?
答案 0 :(得分:0)
您可以使用通知。因此,在视图控制器C中,您可以:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// add notification to be informed if the app becomes active while
// this view controller is active, and if so, to invoke the
// appDidBecomeActive method.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appDidBecomeActive)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
- (void)appDidBecomeActive
{
// do whatever you want in this method. for example, if you did
// a modal segue (or presentViewController) to present this
// view controller's view, then you'd dismiss like thus:
[self dismissViewControllerAnimated:NO completion:nil];
}
- (void)viewWillDisappear:(BOOL)animated
{
// when this view disappears, we should remove the observer on
// the UIApplicationDidBecomeActiveNotification
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIApplicationDidBecomeActiveNotification
object:nil];
}