我正在尝试将委托设置为我的 UITextfield 集合,以便我可以调用resignFirstResponder
我的所有文本字段。我试过的没有回应。
@property (nonatomic, weak) IBOutletCollection(UITextField) NSMutableArray *textFields;
- (void)viewDidLoad
{
[_textFields enumerateObjectsUsingBlock:^(UITextField *textfield, NSUInteger idx, BOOL *stop)
{
textfield.delegate=self;
}];
}
- (BOOL) textFieldShouldReturn:(UITextField *)textFields
{
NSLog(@"textFieldShouldReturn Fired :)");
[_textFields enumerateObjectsUsingBlock:^(UITextField *textfield, NSUInteger idx, BOOL *stop)
{
[textfield resignFirstResponder];
}];
return YES;
}