zoukankan      html  css  js  c++  java
  • UIAlertView

      我感觉UIActionSheet和UIAlertView的用法差不多,想用哪个,根据公司要求和个人爱好。

    #import "ViewController.h"

    @interface ViewController ()<UIAlertViewDelegate>

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];

        button1.frame = CGRectMake(100, 100, 100, 50);

        button1.backgroundColor = [UIColor lightGrayColor];

        [button1 setTitle:@"button1" forState:UIControlStateNormal];

        [button1 addTarget:self action:@selector(showAlertView:) forControlEvents:UIControlEventTouchUpInside];

        [self.view addSubview:button1];

    }

    - (void)showAlertView:(UIButton*)button {

      //Cancel,OK1,OK2,OK3,它们的buttonIndex分别为0,1,2,3

        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hehe" message:@"这是一行描述信息" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK1",@"OK2",@"OK3", nil];

        alertView.delegate = self;

        [alertView show];

    }

    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

        if (0 == buttonIndex) {

            NSLog(@"0000000000");

        } else if (1 == buttonIndex) {

            NSLog(@"1111111111");

        } else if (2 == buttonIndex) {

            NSLog(@"2222222222");

        } else {

            NSLog(@"3333333333");

        }

    }

    - (void)alertViewCancel:(UIAlertView *)alertView{

        NSLog(@"alertViewCancel");

    }

    -(void)willPresentAlertView:(UIAlertView *)alertView{

        NSLog(@"willPresentAlertView");

    }// before animation and showing view

    - (void)didPresentAlertView:(UIAlertView *)alertView{

        NSLog(@"didPresentAlertView");

    }// after animation

    - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex{

        NSLog(@"willDismissWithButtonIndex");

    }// before animation and hiding view

    - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{

        NSLog(@"didDismissWithButtonIndex");

    }// after animation

    // Called after edits in any of the default fields added by the style

    - (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView{

        NSLog(@"alertViewShouldEnableFirstOtherButton");

        return YES;

    }

    @end

  • 相关阅读:
    asp.net(.net 4.0)+ json 分页
    在两张表(A表和B表)里面找出A中不存在B表的记录
    linq to sql 的List<Table> 数据表缓存
    linq 并发冲突概念
    阿里RocketMq节约成本
    阿里巴巴java手册异常日志
    阿里巴巴java手册安全规约
    阿里巴巴java手册单元测试
    Spring boot自定义starter
    MongoDB权限
  • 原文地址:https://www.cnblogs.com/yyt-hehe-yyt/p/4732839.html
Copyright © 2011-2022 走看看