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

  • 相关阅读:
    电机调速作业
    迟到的大作业模块分析
    PLC梯形图设计
    电机随笔
    好难
    电机随笔(三)
    电机随笔(二)
    电机随笔 (一)
    机电传动控制直流调速作业
    机电传动控制大作业第一阶段
  • 原文地址:https://www.cnblogs.com/hsxblog/p/4934988.html
Copyright © 2011-2022 走看看