美文网首页
昵称只能由中文或字母组成

昵称只能由中文或字母组成

作者: eb7a9dac29d0 | 来源:发表于2017-07-13 15:18 被阅读0次

    - (void)uploadUserNameDataWithUserName:(NSString *)userName

    {

    NSString *regex = @"(^[\u4E00-\u9FA5A-Za-z]+$)";

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];

    if(![pred evaluateWithObject:userName])

    {

    UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"昵称只能由中文或字母组成" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];

    [alertView show];

    }

    else

    {

    if (userName.length == 0) {

    dispatch_async(dispatch_get_main_queue(), ^{

    [MTCustomAlertView showCustomAlertViewWithContent:@"用户昵称不能为空" andRect:KTOASTRECT andTime:3.0f andObject:self];

    });

    } else if (userName.length > 10) {

    dispatch_async(dispatch_get_main_queue(), ^{

    [MTCustomAlertView showCustomAlertViewWithContent:@"请输入10个以内中文、字母或汉字" andRect:KTOASTRECT andTime:3.0f andObject:self];

    });

    } else {

    if ([MTUnit allSpace:userName]) {

    dispatch_async(dispatch_get_main_queue(), ^{

    [MTCustomAlertView showCustomAlertViewWithContent:@"不能输入空格" andRect:KTOASTRECT andTime:3.0f andObject:self];

    });

    } else {

    _userName = userName;

    NSDictionary *params = @{

    @"userId"  :  [WMUserDataManager readPassWord],

    @"nickname" :  userName

    };

    [self uploadUserInfoNetworking:params];

    [MTNotification postNotificationName:uploadUserHeadImageOrUserNameNote object:self userInfo:nil];

    }

    }

    }

    }

    相关文章

      网友评论

          本文标题:昵称只能由中文或字母组成

          本文链接:https://www.haomeiwen.com/subject/zwwwhxtx.html