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;

        }

     }

  • 相关阅读:
    在centOS上安装oracle出现java.lang.NoClassDefFoundError问题及解决方法
    centos6.5下安装oracle11g
    配置单点登录
    CentOS 环境变量编辑、保存、立即生效的方法
    python如何调用C语言程序
    python生成exe可执行程序
    python的encode()和decode()函数
    python 获取时间
    python修改字符串的值
    python enumerate()函数
  • 原文地址:https://www.cnblogs.com/OIMM/p/4699113.html
Copyright © 2011-2022 走看看