0

Xcode の私の xiphone プロジェクトで、1 つのスプラッシュ スクリーン「a」、最初のビュー「b」、2 番目のビュー「c」、2 番目のビューに「戻る」ボタンがあるとします。今私の仕事は、私のアプリが初めて起動するときに、スプラッシュスクリーンが起動されることです。「b」が表示されます。次に、「c」に進みます。その後、もう一度アプリを起動すると、ビュー「c」が表示されます。ビュー「b」を見たい場合は、ビュー「c」で「戻る」ボタンを押す必要があります。それ以外の場合、ビュー "b" は表示されません。

これは私の問題です。どうすれば問題を解決できますか?

4

1 に答える 1

0

通知を使用できます。したがって、View Controller 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];
}
于 2012-12-23T17:52:10.607 に答える