当前位置: 代码迷 >> Iphone >> 判断textField里头是否有空
  详细解决方案

判断textField里头是否有空

热度:56   发布时间:2016-04-25 05:42:42.0
判断textField里面是否有空

 

效果图:

 

代码:

- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.        //TextField    UITextField *textField=[[UITextField alloc]initWithFrame:CGRectMake(20, 100, 100, 200)];    textField.backgroundColor=[UIColor redColor];    textField.text=@"123";    [self.view addSubview:textField];        NSLog(@"判断textField里面是否为空%i",[self textFieldIsNOTEmpt:textField]);        }//判断textField里面是否有空-(BOOL)textFieldIsNOTEmpt:(UITextField *)textField{    if ([textField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]].length!=0){        return YES;    }else {        return NO;    }}

 

  相关解决方案