ユーザが特定の場所にいるときに、私のアプリに警告表示を表示したい。また、私はこのアラートビューを1回だけ提示したいだけです。別のViewControllerへの移行時にリセットされる変数
if(!hasShownAlertview && GMSGeometryContainsLocation(userLocation.coordinate, testPath, YES)){
hasShownAlertview = YES;
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" [email protected]"Body" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *yesAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"YES", nil) style:UIAlertActionStyleDefault handler:
^(UIAlertAction *action){
}];
UIAlertAction *noAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"NO", nil) style:UIAlertActionStyleDefault handler:
^(UIAlertAction *action){
}];
[alertController addAction:noAction];
[alertController addAction:yesAction];
[self presentViewController:alertController animated:YES completion:nil];
}
}
問題は次のとおりです:ユーザーがその場所にとどまっている間、私は、別のViewControllerに行けば、アラートビューは、そののViewControllerに再び示されている。このために、 は、私は次のコードを持っています。この理由は、新しいViewControllerが表示される直前にhasShownAlertview
がNOに設定されているため、アラートビューが再度表示されることです。
どうすればこの問題を解決できますか?
で
hasShownAlertView
変数を取得しますか? – Shreyankこれはivファイルとして.hファイル内で宣言されています –
'hasShownAlertview'の' Strong'を作成します – Shreyank