zoukankan      html  css  js  c++  java
  • 弹窗的几种方式

    弹窗的几种方式 (苹果原生)

    • UIAlertView : 从中间弹出来(9.0以后过期了)

    • 实现代码如下:
    // 方式一:(9.0过期了)
    
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"BabyWong的标题" message:@"BabyWong的内容" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    
        // 一定要调用show方法
        [alertView show];
    
    
    • UIActionSheet : 从底部弹出来(9.0以后过期了)

    • 实现代码如下:
     // 方式二:(9.0过期了)
        UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"BabyWong的标题" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:@"其他", nil];
    
        // 一定要调用show方法
        [sheet showInView:self];
    
    
    • UIAlertController == UIAlertView + UIActionSheet 主流弹窗方式8.0开始可以使用,更灵活,,可以选择弹窗样式(中间 / 底部)

    • 实现代码如下:
    
       UIAlertController *controller = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    
        [controller addAction:[UIAlertAction actionWithTitle:@"收藏" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            WWLog(@"点击了收藏按钮");
        }]];
    
         [controller addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
             WWLog(@"取消");
         }]];
    
        [controller addAction:[UIAlertAction actionWithTitle:@"举报" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
            WWLog(@"点击了[举报]按钮");
        }]];
    
    // 一定要手动modal出来
        [self.window.rootViewController presentViewController:controller animated:YES completion:nil];
    
    
    • Posted by 博客园·BabyWong
    • 原创文章,版权声明:自由转载-非商用-非衍生-保持署名BabyWong
    • 邮箱 wenmeiwong520@gmail.com
    Me WMHaa
  • 相关阅读:
    树莓派更新镜像源于镜像源推荐
    树莓派安装系统并设置中文界面
    查询linux文件的MD5值
    iOS安全攻防(二十三):Objective-C代码混淆
    【v2.x OGE教程 20】粒子效果
    JNI_最简单的Java调用C/C++代码
    JavaScript面向对象精要(一)
    频繁模式挖掘apriori算法介绍及Java实现
    hdu1573X问题(不互素的中国剩余定理)
    hive优化之自己主动合并输出的小文件
  • 原文地址:https://www.cnblogs.com/WMHaa/p/4983984.html
Copyright © 2011-2022 走看看