zoukankan      html  css  js  c++  java
  • iOS UIAlertController UIAlertView 几秒钟消失的提示

    UIAlertView版(iOS9.0以后废弃)
    //操作提示
    - (void)showAlert:(NSString *)message disappear:(BOOL)disappear {
        dispatch_async(dispatch_get_main_queue(), ^{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:!disappear?@"OK":nil otherButtonTitles:nil, nil];
        [alert show];
        if (disappear) {
            double delayInSeconds = 1.2;
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                [alert dismissWithClickedButtonIndex:alert.cancelButtonIndex animated:YES];
            });
        }
             });
    }
    
    //调用
    [self showAlert:@"介里系累容" disappear:YES];
    UIAlertController版(苹果支持用的)
    //操作提示
    - (void)showDismissWithTitle:(NSString *)title  message:(NSString *)message parent:(UIViewController *)parentController {
        dispatch_async(dispatch_get_main_queue(), ^{
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
            [self presentViewController:alert animated:YES completion:nil];
    
            double delayInSeconds = 1.2;
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                [alert dismissViewControllerAnimated:YES completion:nil];
            });
        });
    }
    
    
    
     
    
    
    //调用
    [self showDismissWithTitle:@"" message:@"累容载介里" parent:self];
  • 相关阅读:
    OEA框架学习:缓存
    2012年 博文整理
    技术支持经验总结
    OEA框架学习:元数据设计
    安装后新建Android出现“AndroidManifest.xml 系统找不到指定的文件”解决方案
    Android控件学习笔记之 GridView(实现九宫格)
    获取url地址中主机的域名
    C# 语音读取字符串
    JSON省市联动
    MOTO Droid手机自定义本地铃声设置方法
  • 原文地址:https://www.cnblogs.com/gaozhang12345/p/10461111.html
Copyright © 2011-2022 走看看