zoukankan      html  css  js  c++  java
  • IOS学习之路二十二(UIAlertView获得文本框内容及添加北京图片)

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

    效果图大体如下:

    下面简单介绍一下UIAlertView

    alertViewStyle属性有以下三种选项:

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

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

    UIAlertViewStylePlainTextInput        UIAlertViewStyleSecureTextInput

    UIAlertViewStylePlainTextInput)                                (UIAlertViewStyleSecureTextInput)

    UIAlertViewStyleLoginAndPasswordInput

    (UIAlertViewStyleLoginAndPasswordInput)

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

    1. #pragma mark 弹出菜单  
    2.   
    3. - (IBAction)showMenu:(id)sender {  
    4.       
    5.     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"修改Webservice请求地址"  
    6.                                                         message:@"请输入地址:(http://192.168.6.12)"  
    7.                                                        delegate:self cancelButtonTitle:@"确定"  
    8.                                               otherButtonTitles:@"取消", nil];  
    9.     [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];  
    10.       
    11.     [alertView show];   
    12.     //背景View  
    13.     UIView *additonBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, alertView.frame.size.width-30, alertView.frame.size.height-20)];  
    14.     additonBackgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bag3.jpg"]]; //添加背景图片  
    15.   
    16.     [alertView insertSubview:additonBackgroundView atIndex:1];  
    17.   
    18. }  
    19.   
    20. #pragma mark   获得输入框里的值  
    21. - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{  
    22.     NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex];  
    23.     if ([buttonTitle isEqualToString:@"确定"]){  
    24.           UITextField *tf=[alertView textFieldAtIndex:0];//获得输入框  
    25.         NSString * requestedURL=tf.text;//获得值  
    26.   
    27.     }  
    28. }  


    转载请注明:

    新浪微博:http://weibo.com/u/3202802157

  • 相关阅读:
    json-c初探(一)
    Java程序员跳槽的首选面试题最新合集(2021下半年),初中高级程序员!
    R语言版本的bedtools--bedtoolsr
    使用R语言(cpm包)进行序列变点(change point)检测
    三款PHP大马,已解密、去后门
    php 取出数据表数据放入数组并排序
    VimTutor每讲小结
    记录一下c++学习过程
    vmware fusion关闭自动挂起(suspend)的方法
    mac中安装mysqlclient出错error: command 'clang' failed with exit status 1的解决办法
  • 原文地址:https://www.cnblogs.com/lixingle/p/3312954.html
Copyright © 2011-2022 走看看