ユーザーが UINavigationBar の [戻る] ボタンを押していることを検出する方法について複数の質問を見ましたが、その回答では問題が解決しません。
実際、ユーザーが UINavigationBar の「戻る」ボタンを押したときに UIAlertView を表示して、「変更を保存しますか?」と尋ねたいと思います。.
ユーザーが [戻る] ボタンを押したときに UIAlertView を表示できますが (次のスニペットを使用)、前のビューが同時にポップされます。そして、私はこの振る舞いを望んでいません! 前のビューをポップする前に、アプリがユーザーの回答を待つことを望んでいます...
-(void) viewWillDisappear:(BOOL)animated
{
if ([self isMovingFromParentViewController])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Avertissement" message:@"Voulez-vous enregistrer les modifications effectuées ?" delegate:self cancelButtonTitle:@"Retour" otherButtonTitles:@"Oui", @"Non", nil];
[alert show];
}
[super viewWillDisappear:animated];
}
助けてくれてありがとう...