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];
  • 相关阅读:
    ajax配置项中的type与method
    解决 eclipse出现 Address already in use: bind,以及tomcat端口占用
    网络流定理总结
    题解说明
    sol
    题解P4201: [NOI2008]设计路线
    题解 Luogu P5434: 有标号荒漠计数
    题解 Luogu P2499: [SDOI2012]象棋
    JZOJ-2019-11-8 A组
    JZOJ-2019-11-7 A组
  • 原文地址:https://www.cnblogs.com/gwkiOS/p/4990206.html
Copyright © 2011-2022 走看看