[textField setErrorMessageInValidationBlock:^NSString *(NSString *stringToValidate)
{
NSString *errorMessage = nil;
if ([stringToValidate stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]].length == 0)
{
errorMessage = @"is required.";
}
return errorMessage;
}];
// To implement the - (BOOL)textFieldShouldReturn:(UITextField *)textField
// method specified in the UITextFieldDelegate protocol is only necessary
// to specify a block of code to be executed instead of the method thus only
// it needs to spend the blocks describing a specific behavior as an argument
// to a specific instance of the field.
[textField setShouldReturn:^BOOL(UITextField *textField)
{
[textField endEditing:YES];
return NO;
}];
JRTForm 可以通过 CocoaPods 获取,要安装它,只需将以下行添加到您的 Podfile 中
pod 'JRTForm'
只需将 JRTForm 目录从演示项目拖放到您的项目中。就是这样。