• 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;

        }

     }

  • 相关阅读:
    app专项测试之稳定性测试-monkey测试
    Mac下Fiddler的安装启动。
    测试环境搭建和部署(在Linux环境下搭建jdk+Tomcat+mysql环境和项目包的部署)
    mysql如何用sql语句修改表字段?
    VMware虚拟机出现“正在使用中”如何解决?
    Opencv2.1+vs2008生成不依赖编译环境的exe文件
    VS2008在win7下不时出现Microsoft Incremental Linker已停止工作
    没有找到opencv_core231d.dll运行结果不能显示
    Mat类型与IplImage类型之间相互转换
    获取当前可执行文件的路径(绝对路径)
  • 原文地址:https://www.cnblogs.com/OIMM/p/4699113.html
Copyright © 2020-2023  润新知