• 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];
  • 相关阅读:
    线程池类型场景和问题
    react Antdesign Select添加全选功能
    API与ESB 、ServiceMesh、微服务究竟关系如何?
    RabbitMQ四种Exchange类型
    RabbitMq安装
    kafka 部署
    共享文件夹重启后每次都要输入密码
    algorithm 12 partial_sort_copy
    algorithm 11 nth_element
    algorithm 11 none_of
  • 原文地址:https://www.cnblogs.com/gwkiOS/p/4990206.html
Copyright © 2020-2023  润新知