2016-05-31 4 views
0

トップビューコントローラーからアプリを問題にして再初期化したい。私のアプリは最初からビューをリロードしたい。 私はapplicationWillEnterForeground方法でこれを試してみました:iOS:バックビューコントローラーからアプリを再初期化する

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]]; 
     ActivityController *destViewController = (ActivityController *)[storyboard instantiateViewControllerWithIdentifier:@"ActivityView"]; 
     [self.navigationController pushViewController:destViewController animated:YES]; 

しかし、それは動作しません。

答えて

0

アプリがバックグラウンドで実行したくない場合は、アプリのInfo.plist

0

applicationDidEnterBackgroundとapplicationWillEnterForeground、

[[NSNotificationCenter defaultCenter] postNotificationName:@"popToRoot" object:nil]; 

とあなたのrootViewControllerののviewDidLoad(中にtrueUIApplicationExitsOnSuspendを設定することができますアプリの起動時に常に表示される)を追加します。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popToRootViewControllerAnimated) name:@"popToRoot" object:nil]; 

は、その後、あなたのrootViewControllerでメソッドを作成します。

- (void)popToRootViewControllerAnimated 
{ 
    [self.navigationController popToRootViewControllerAnimated:YES]; 
} 

あなたは[self.navigationController popToViewController:ActivityController animated:NO];代わりのpopToRootを使用する必要があります。

詳細はthis answerを参照してください。

関連する問題