Ios 如何防止UIAlertController被解雇
我有一些警报,显示有一些延迟。有两个按钮,一个是取消和暂停。当我点击“暂停”按钮时,该警报应在视图上保留一段时间。当点击“取消”按钮时,我想解除警报,如果没有发生任何操作,我想自动解除警报。 我正在使用这个代码Ios 如何防止UIAlertController被解雇,ios,objective-c,xcode,grand-central-dispatch,uialertcontroller,Ios,Objective C,Xcode,Grand Central Dispatch,Uialertcontroller,我有一些警报,显示有一些延迟。有两个按钮,一个是取消和暂停。当我点击“暂停”按钮时,该警报应在视图上保留一段时间。当点击“取消”按钮时,我想解除警报,如果没有发生任何操作,我想自动解除警报。 我正在使用这个代码 dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); dispatch_after(popTime, dispatch_get_
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;
});