如何防止解雇UIAlertController

时间:2017-06-05 11:53:26

标签: ios objective-c xcode grand-central-dispatch uialertcontroller

我有一些警报,并显示有一些延迟。有2个按钮,一个是取消和暂停。当我点击暂停按钮时,警报应保留在视图上一段时间。当点击取消想要解除警报时,如果没有发生任何动作想要自动解除警报。 我正在使用此代码

dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
                dispatch_after(popTime, dispatch_get_main_queue(), ^(void){

                    NSLog(@"%f",delayInSeconds);

                    UIAlertController* alertDisplay1AutoMatic = [UIAlertController alertControllerWithTitle:displayData.title
                                                                                                    message:displayData.content
                                                                                             preferredStyle:UIAlertControllerStyleAlert];


                    [self.window.rootViewController presentViewController:alertDisplay1AutoMatic animated:YES completion:nil];


                    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel
                                                                         handler:^(UIAlertAction * action) {


                                                                                 [self.window.rootViewController dismissViewControllerAnimated:YES completion:nil];


                                                                         }];

                    self.PauseAction = [UIAlertAction actionWithTitle:@"Pause" style:UIAlertActionStyleDefault
                                                                        handler:^(UIAlertAction * action) {




                                                                        }];


                    [self performSelector:@selector(dismissUIAlertViewType:) withObject:alertDisplay1AutoMatic afterDelay:10];

                    [alertDisplay1AutoMatic addAction:cancelAction];
                    [alertDisplay1AutoMatic addAction: self.PauseAction];
                    alertDisplay1AutoMatic.actions[1].enabled = NO;

                });

0 个答案:

没有答案