zoukankan      html  css  js  c++  java
  • iOS警示框—判断是否有空格和回车

    //输入框是否为空(判断空格和回车)
    -(BOOL)isEmpty:(NSString *)string
    {
        if (!string) {
            return YES;
        }else
        {
            NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
            NSString *str = [string stringByTrimmingCharactersInSet:set];
            if (str.length == 0) {
                return YES;
            }else{
                return NO;
            }
        }
    }
    
    //警示框
    -(void)alert{
        
        NSString *message = nil;
        if([self isEmpty:self.userTextField.text]){    //调用函数把空格处理为0
            message = @"请输入用户名";
        }else if(self.pwdTextField.text.length == 0){    //密码可以带空格
            message = @"请输入密码";
        }
        if(message)
        {
            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:message preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
            UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
            //    UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"警告" style:UIAlertActionStyleDestructive handler:nil];
            [alertController addAction:action1];
            [alertController addAction:action2];
            //    [alertController addAction:action3];
            [self presentViewController:alertController animated:YES completion:nil];
        }
    }
    

      

  • 相关阅读:
    fs.readdirSync
    symbol
    vuex-count
    webpack2.0
    关于vuex报错
    store
    .NET MVC 验证码
    SQLServer 加密
    IE10、IE11下SCRIPT5009: “__doPostBack”未定义
    Sql Server 增加字段、修改字段、修改类型、修改默认值
  • 原文地址:https://www.cnblogs.com/ios988/p/5289703.html
Copyright © 2011-2022 走看看