• 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

  • 相关阅读:
    paip.提升用户体验论文本编辑器的色彩方案
    paip.c++ qt 项目工程互相引用的方法
    paip.提升用户体验=c++ qt 字体切换功能缺少的总结..
    paip.提升用户体验自定义<<移位操作符重载
    paip.提升用户体验c++ gcc 命令语法着色搭配方案
    paip.c++ 指针跟引用的区别.
    paip.c++ qt 目录遍历以及文件操作
    paip. c++ 调用.net dll 最好方式powershell 使用总结.
    paip.提升用户体验c++ 源码字体自定义制造总结
    paip.提升用户体验c++ Qt5 实现程序图标以及动态托盘闪烁图标
  • 原文地址:https://www.cnblogs.com/yyt-hehe-yyt/p/4732839.html
Copyright © 2020-2023  润新知