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;

        }

     }

  • 相关阅读:
    4.关于QT中的QFile文件操作,QBuffer,Label上加入QPixmap,QByteArray和QString之间的差别,QTextStream和QDataStream的差别,QT内存映射(
    PlSql加入数据库链接
    UserScan的处理流程分析
    第八十八题(金山笔试题,字符串移动)
    4Sum_leetCode
    LeetCode Add Binary
    Hibernate or JPA Annotation中BLOB、CLOB注解写法
    配置Nginx防止直接用IP訪问Webserver
    Java集合系列之TreeMap源代码分析
    使用Application Loader上传APP流程解读[APP公布]
  • 原文地址:https://www.cnblogs.com/OIMM/p/4699113.html
Copyright © 2011-2022 走看看