2016-07-28 6 views
0

私はここで関連するすべての記事をほぼ読んでいますが、警告を消すことはできません。誰も助けることができますか?それほど難しくはありません...UIAlertViewControllerの警告モーダルはUIAlertActionを追加しても解除できません

P.S. DEFAULTACTIONのコールバックでは、私は両方を試してみました:

#import "ViewController.h" 

@interface ViewController() 
@property (strong, nonatomic) UIAlertController *alert; 
@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)viewDidAppear:(BOOL)animated { 
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Reminder" 
                    message:@"" 
                  preferredStyle:UIAlertControllerStyleAlert]; 
    self.alert = alert; 
    self.alert.message = @"You just logged in. The tab will be refreshed"; 
    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault 
                  handler:^(UIAlertAction * action) { 
                   [self dismissViewControllerAnimated:YES completion:^{ 
                    NSLog(@"webview is reloading..."); 
                   }]; 

                  }]; 

    [self.alert addAction:defaultAction]; 
    [self presentViewController:self.alert animated:YES completion:nil]; 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 
+0

これはiOSシミュレータの問題です。それはNSLog(@ "ok ...")とうまく動作します。デバイス上のソリューション。今Appleに問題を提出しています... – lkahtz

+0

これは主にアップルのバグであるので、私はこの質問をトピックとしてクローズすることに投票しています。できるだけ速やかにテクニカルサポートチケットを開きます。私が詳細を知る前に、私はこの質問を今閉じています。 – lkahtz

答えて

0

閉じる:

[self dismissViewControllerAnimated:YES completion:^{ 
                    NSLog(@"ok..."); 
                   }]; 

NSLog(@"ok..."); 

を両運のうち、

私のコードです。ちょっと調整するだけです。

- (void)viewDidAppear:(BOOL)animated { 
    self.alert = [UIAlertController alertControllerWithTitle:@"Reminder" 
                    message:@"You just logged in. The tab will be refreshed" 
                  preferredStyle:UIAlertControllerStyleAlert]; 

    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel            handler:^(UIAlertAction * action) { 
//alert dismisses itself 
    }]; 

    [self.alert addAction:defaultAction]; 
    [self presentViewController:self.alert animated:YES completion:nil]; 
} 
1

あなたは

[self dismissViewControllerAnimated:YES completion:^{ 
       NSLog(@"webview is reloading..."); 
      }]; 

使用それは警告コントローラが存在した後、それはログを表示却下あなたの現在のビューcontrtollerを閉じますself.Ifそれはそれを却下します。

- (void)viewDidAppear:(BOOL)animated 
{ 
     UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Reminder" message:@"" preferredStyle:UIAlertControllerStyleAlert]; 
    self.alert = alert; 
    self.alert.message = @"You just logged in. The tab will be refreshed"; 
       UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) 
      { 
        NSLog(@"Ok button pressed..");  
        NSLog(@"webview is reloading..."); 
     }]; 
    }]; 
    [self.alert addAction:defaultAction]; 
    [self presentViewController:self.alert animated:YES completion:nil]; 
} 
関連する問題