• 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

  • 相关阅读:
    Pycharm软件更换pip默认安装源为国内安装源
    电商网站名词item>SKU与SPU
    Linux通过端口号查看使用进程结束进程
    window系统下的pycharm对虚拟机中的Ubuntu系统操作MySQL数据库
    JAVA项目常用的异常处理情况总结
    公文流转系统(未完成)
    《程序员修炼之道》读后感(三)
    Java文件操作递归遍历文件目录
    Java Web初试连接数据库完成学生信息录入
    JavaJFrame窗口实现新课程添加
  • 原文地址:https://www.cnblogs.com/yyt-hehe-yyt/p/4732839.html
Copyright © 2020-2023  润新知