ios获取textfield的输入值

来源:互联网 发布:linux 字符编码 编辑:程序博客网 时间:2024/06/05 07:08

ios判断textfield的输入值大小,比方说实时 判断textField的值 是否大于10000 或者是否大于几位数

1,遵守 UITextFieldDelegate


2.

-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

{

    NSString *text = [textField.textstringByReplacingCharactersInRange:rangewithString:string];

        

       //if (textField.text.length >4)

        if ([textintegerValue] >10000) {

            MBProgressHUD *hud = [MBProgressHUDshowHUDAddedTo:[UIApplicationsharedApplication].keyWindowanimated:YES];

            hud.mode =MBProgressHUDModeText;

            hud.labelText =@"提示" ;

            hud.detailsLabelText =@"金额不能大于1万元";

            hud.removeFromSuperViewOnHide =YES;

            //    hud.dimBackground = YES;

            [hud hide:YESafterDelay:2];

            returnNO;

        } 

    

    returnYES;

}


0 0
原创粉丝点击