zoukankan      html  css  js  c++  java
  • 警告框样式(带输入框)

    今天写项目要用到警告框带输入框的,于是就自己做了个小demo.

    效果图大体如下:


    下面简单介绍一下UIAlertView

    alertViewStyle 属性有以下三种选项:

     UIAlertViewStylePlainTextInput 添加一个普通输入框 
     UIAlertViewStyleSecureTextInput   密码输入框
     UIAlertViewStyleLoginAndPasswordInput  普通输入框加密码输入框

    下面分别来看看这三种属性的效果:

    UIAlertViewStylePlainTextInput          UIAlertViewStyleSecureTextInput

    ( UIAlertViewStylePlainTextInput )                                (UIAlertViewStyleSecureTextInput)

    UIAlertViewStyleLoginAndPasswordInput

    (UIAlertViewStyleLoginAndPasswordInput)

    下面附上自己写的部分关键代码:

    #pragma mark 弹出菜单
    
    - (IBAction)showMenu:(id)sender {
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"修改Webservice请求地址"
                                                            message:@"请输入地址:(http://192.168.6.12)"
                                                           delegate:self cancelButtonTitle:@"确定"
                                                  otherButtonTitles:@"取消", nil];
        [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
        
        [alertView show]; 
        //背景View
        UIView *additonBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, alertView.frame.size.width-30, alertView.frame.size.height-20)];
        additonBackgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bag3.jpg"]]; //添加背景图片
    
        [alertView insertSubview:additonBackgroundView atIndex:1];
    
    }
    
    #pragma mark   获得输入框里的值
    - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
        NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex];
        if ([buttonTitle isEqualToString:@"确定"]){
              UITextField *tf=[alertView textFieldAtIndex:0];//获得输入框
            NSString * requestedURL=tf.text;//获得值
    
        }
    }
  • 相关阅读:
    [QT]
    [QT]
    企业内搜索引擎项目(一):架构
    Muduo网络库实战(二):实现服务器与客户端的连接
    Muduo网络库实战(一):安装和配置
    Xapian实战(一):环境搭建 + 简介
    Centos 6.5升级gcc : 源码安装 + rpm安装
    Hadoop学习笔记(二)——插件安装和使用(Hadoop Eclipse)
    Hadoop学习笔记(三) ——HDFS
    Hadoop学习笔记(一)——安装与配置
  • 原文地址:https://www.cnblogs.com/stephen-init/p/4259946.html
Copyright © 2011-2022 走看看