标签:
//如果输入的昵称是字母,判断是否合格
if(self.nickNameText){
for (int i=0; i<self.nickNameText.length; i++) {
NSRange range=NSMakeRange(i,1);
NSString *subString=[self.nickNameText substringWithRange:range];
const char *cString=[subString UTF8String];
if (strlen(cString)==3)
{
NSLog(@"昵称是汉字");
if(self.nickNameText.length<2||self.nickNameText.length>8){
UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"不要输入低于2个或者高于8个" message:@"您输入的昵称格式有误,请重新输入" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alertView show];
return;
}
}else if(strlen(cString)==1)
{
NSLog(@"昵称是字母");
if(self.nickNameText.length<4||self.nickNameText.length>16){
UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"不要输入低于4个或者高于16个" message:@"您输入的昵称格式有误" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alertView show];
return;
}
}
}
}
标签:
原文地址:http://blog.csdn.net/darongzi1314/article/details/42777891