继承UITextfield
.h文件
#import<UIKit/UIKit.h>
@protocol keyInputTextFieldDelegate<NSObject>
-(void)deleteBackward;
@end
@interface UITextFieldKeybordDelete:UITextField
@property (nonatomic, weak)id<keyInputTextFieldDelegate>keyInputDelegate;
@end
.m文件
-(void)deleteBackward
{
[super deleteBackward];
if (_keyInputDelegate && [_keyInputDelegate respondsToSelector:@selector(deleteBackward)]) {
[_keyInputDelegate deleteBackward];
}
}
使用方法
是需要在用到的页面中引入并实现代理方法即可。