1.UITextField
代理方法:
//是否允许开始编辑,返回否则不允许编辑
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField;
//开始编辑时调用(成为第一响应者became first responder)
-(void)textFieldDidBeginEditing:(UITextField *)textField;
//是否允许结束编辑,返回否则不允许结束编辑
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField;
//结束编辑时调用
-(void)textFieldDidEndEditing:(UITextField *)textField;
//结束编辑时调用,当此方法实现上面的方法将被取代
-(void)textFieldDidEndEditing:(UITextField *)textField reason:(UITextFieldDidEndEditingReason)reason;
//是否允许改变文本框内容,返回否则文本框的内容无法被改变
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
//是否响应清除按钮,返回否则清除按钮无效
-(BOOL)textFieldShouldClear:(UITextField *)textField;
//是否响应return键,返回否则return键无效
-(BOOL)textFieldShouldReturn:(UITextField *)textField;
属性:
clearButtonMode:清除按钮的模式
/**
* UITextFieldViewModeNever //不出现
* UITextFieldViewModeWhileEditing //当编辑时出现
* UITextFieldViewModeUnlessEditing //编辑之外的场景出现
* UITextFieldViewModeAlways //总是出现
*/
2.字典遍历:
[dictionary enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
[nationData setValue:obj forKey:key];
}];
setValue: forKeyPath:方法的实现
1.先查看有没有对应key值的set方法,如果有则调用set方法
2.查看有没有与key值相同的property属性,如果有则赋值
3.查看有没有与key值相同的成员变量,如果有则赋值
4.如果以上都没有实现则报错