zoukankan      html  css  js  c++  java
  • iOS开篇——UI之UIActionSheet

    UIActionSheet在iOS8.3之后已不建议使用。 可以使用

    UIAlertController+UIAlertControllerStyleActionSheet获得同样的效果

    创建UIActionSheet

        UIActionSheet * as = [[UIActionSheet alloc]initWithTitle:@"选择一个英雄" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"德玛" otherButtonTitles:@"琴女", nil];
    //设置样式
        as.actionSheetStyle = UIActionSheetStyleBlackOpaque;

    实现协议方法 

    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
        switch (buttonIndex) {
            case 0:
                NSLog(@"这是第0个");
                break;
            case 1:
                NSLog(@"这是第1个");
                break;
            default:
                break;
        }
    }

    使用UIAlertController+UIAlertControllerStyleActionSheet实现

        UIAlertController * ac = [UIAlertController alertControllerWithTitle:@"选择一个英雄" message:@"没事" preferredStyle:UIAlertControllerStyleActionSheet];
        [ac addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"取消");
        }]];
        
        [ac addAction:[UIAlertAction actionWithTitle:@"德玛" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"德玛");
        }]];
        
        [self presentViewController:ac animated:YES completion:nil];
  • 相关阅读:
    mycat分表扩展之全局序列(数据库方式)
    mycat分表扩展之按日期(天)分片
    mycat分表扩展之范围约定
    mycat分表扩展之分片枚举
    jdk导入证书链步骤说明
    oracle md5加密函数
    oracle常用(11g)
    oracle 11g 常规sql
    oracle归档日志
    oracle定时任务
  • 原文地址:https://www.cnblogs.com/gwkiOS/p/4990206.html
Copyright © 2011-2022 走看看