zoukankan      html  css  js  c++  java
  • UIActionSheet

    #import "RootViewController.h"

    @interface RootViewController ()<UIActionSheetDelegate>

    @end

    @implementation RootViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        

        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 200, 50)];

        button.layer.borderWidth = 2;

        [button setTitle:@"showSheet" forState:(UIControlStateNormal)];

        [button setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];

        [self.view addSubview:button];

        [button addTarget:self action:@selector(show) forControlEvents:(UIControlEventTouchUpInside)];

        

    }

    - (void)show {

        //UIActionSheet , 继承于UIView .

        //创建方法

        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"提示" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"destructiveButton" otherButtonTitles:@"1", @"2", @"3", nil];

        actionSheet.title = @"名字";//这里的 title 就是 创建方法里面的initWithTitle

        actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;//设置样式

        //按钮的index destructiveButton , 1 ,2, 3, cancel , 分别是0 1 2 3 4

        /*//四种样式

        UIActionSheetStyleDefault

        UIActionSheetStyleAutomatic

        UIActionSheetStyleBlackOpaque

        UIActionSheetStyleBlackTranslucent

         */

        [actionSheet showInView:self.view];

         

        [actionSheet release];

    }

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{//代理里面的方法, 点击了哪个按钮

        if (0 == buttonIndex) {

            NSLog(@"0");

        } else if (1 == buttonIndex) {

            NSLog(@"1");

        } else if (2 == buttonIndex) {

            NSLog(@"2");

        } else if (3 == buttonIndex) {

             NSLog(@"3");

         } else {

            NSLog(@"4");

        }

    }

    @end

  • 相关阅读:
    文件批量改名(有规律)
    js阻止事件冒泡(phpcms,浮窗第一次10秒弹出后每30秒弹出,动态更换日期)
    关于阿里云ECS Centos 5/6/7 Linux Glibc库严重安全漏洞修复方法
    js中div显示和隐藏钮为什么页面总是跳一下到最上面
    ssh 或 putty 连接linux报错解决方法
    phpcms v9编辑器上传图片是否添加水印
    Linux CURL的安装和使用
    phpcms v9全站点击量排行代码
    MySQL manager or server PID file could not be found!
    linux命令技巧
  • 原文地址:https://www.cnblogs.com/hsxblog/p/4934988.html
Copyright © 2011-2022 走看看