zoukankan      html  css  js  c++  java
  • UIAlertView

    #import "ViewController.h"

    @interface ViewController ()

     

    @end

     

    @implementation ViewController

     

    - (void)viewDidLoad {

     UIButton *button1=[UIButton buttonWithType:UIButtonTypeCustom];

        button1.backgroundColor=[UIColor greenColor];

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

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

        [self.view addSubview:button1];

     }

    -(void)showMyAlertView:(id)sender{

        //初始化一个UIAlertView

        UIAlertView *alertView1=[[UIAlertView alloc]initWithTitle:@"warning" message:@"当前无网络连接" delegate:self cancelButtonTitle:@"cansel" otherButtonTitles:nil, nil];

        alertView1.tag=100;//设置tag值

        [alertView1 addButtonWithTitle:@"确定"];

        //添加提示框展示的按钮;也可以在otherButtonTitles:后面直接添加有的只有一个取消,那么otherButtonTitles:后面写一个nil就可以了,

    //    alertView1.title=@"alertView";//设置提示框标题,设置后警告变为alertView

    //    alertView1.message=@"还是那个提示框的message";

    //    NSLog(@"%d",alertView1.visible);//提示框是否可见(只读)

    //    NSLog(@"%d",(int)alertView1.numberOfButtons);//按钮个数

    //    NSLog(@"%@",[alertView1 buttonTitleAtIndex:0]);//获取提示框指定按钮的标题

    //    NSLog(@"%d",(int)[alertView1 cancelButtonIndex]);//取消按钮的索引

    //    NSLog(@"%d",(int)alertView1.firstOtherButtonIndex);//第一个按钮的索引

        

    //    alertView1.alertViewStyle=UIAlertViewStyleLoginAndPasswordInput;//带有明文输入框

        //    UIAlertViewStyleDefault = 0,//无

        //    UIAlertViewStyleSecureTextInput,//明文

        //    UIAlertViewStylePlainTextInput,//暗文

        //    UIAlertViewStyleLoginAndPasswordInput//一明一暗

    //    UITextField *text1=[alertView1 textFieldAtIndex:0];//获取第一个输入框

    //    UITextField *text2=[alertView1 textFieldAtIndex:1];//获取第二个输入框

    //    text1.placeholder=@"请输入账号";

    //    text2.placeholder=@"请输入密码";

    //    text1.text=@"http://";//输入网址以便连接

    //    text1.clearButtonMode=UITextFieldViewModeWhileEditing;

        //让提示框展示

        [alertView1 show];

        

    }

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

    {

        NSLog(@"hello %d",(int)buttonIndex);

        switch (buttonIndex) {

            case 0:

                NSLog(@"调用0");

                break;

            case 1:

            {

                NSLog(@"调用1");

                UIAlertView *alertView1=[[UIAlertView alloc]initWithTitle:@"警告" message:@"当前无网络连接" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];

                [alertView1 addButtonWithTitle:@"确定"];

                [alertView1 show];

            }

                break;

            default:

                break;

        }

     }

  • 相关阅读:
    Python爬虫系列(六):搜索文档树
    Python爬虫系列(五):分析HTML结构
    Python爬虫系列(四):Beautiful Soup解析HTML之把HTML转成Python对象
    Python爬虫系列(三):requests高级耍法
    Python爬虫系列(二):requests基础
    Python爬虫系列(一):从零开始,安装环境
    Python操作rabbitmq系列(六):进行RPC调用
    Python操作rabbitmq系列(五):根据主题分配消息
    Python操作rabbitmq系列(四):根据类型订阅消息
    Django使用模板进行动态局部刷新
  • 原文地址:https://www.cnblogs.com/OIMM/p/4699113.html
Copyright © 2011-2022 走看看