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

  • 相关阅读:
    别闹了,这些都不是数字化转型
    对不起,“下一代ERP”仍旧是现在的ERP
    这世界真小
    SAP S4HANA 2020 Fully-Activated Appliance 虚拟机版分享
    花费巨资参加SAP培训真的有用吗?
    剑指 Offer 07. 重建二叉树
    剑指 Offer 06. 从尾到头打印链表
    剑指 Offer 05. 替换空格
    剑指 Offer 04.二维数组中的查找
    剑指 Offer 03. 数组中重复的数字
  • 原文地址:https://www.cnblogs.com/yyt-hehe-yyt/p/4732839.html
Copyright © 2011-2022 走看看