iOS8 UIKeyInput protocol
来源:互联网 发布:苹果4s怎么升级4g网络 编辑:程序博客网 时间:2024/05/22 02:31
先上链接
http://stackoverflow.com/questions/25371254/how-to-detect-delete-key-on-an-uitextfield-in-ios-8
点击打开链接
项目中用到输入电话号码再进行格式化显示,在删除的时候,点击退格键 代理deleteBackWard不执行,
网上找了好多,说是ios8的bug,确实在ios7上是没问题的,后来找到了大神的文章,就豁然开朗了,
注意:这篇文章里用到的是一个私有 api,但是据解答者说 是可以上线的,我决定先当小白鼠吧
- (BOOL)keyboardInputShouldDelete:(UITextField *)textField { BOOL shouldDelete = YES; if ([UITextField instancesRespondToSelector:_cmd]) { BOOL (*keyboardInputShouldDelete)(id, SEL, UITextField *) = (BOOL (*)(id, SEL, UITextField *))[UITextField instanceMethodForSelector:_cmd]; if (keyboardInputShouldDelete) { shouldDelete = keyboardInputShouldDelete(self, _cmd, textField); } } if (![textField.text length] && [[[UIDevice currentDevice] systemVersion] intValue] >= 8) { [self deleteBackward];
return NO;// 这里 要是不想让自动删除的时候 就在这里return no,注掉上面的几行代码
} return shouldDelete;}
需要的处理代码 都再deleteBackward
- (void)deleteBackward 是UIKeyInput的代理,在子类中重写即可
0 0
- iOS8 UIKeyInput protocol
- UIKeyInput, UITextInput
- swift语言IOS8开发战记16 Protocol and Map
- ios8
- iOS8
- iOS8
- iOS8
- iOS8
- iOS8
- Protocol
- protocol
- Protocol
- protocol
- @protocol
- Protocol
- Protocol
- protocol
- protocol
- 文件系统
- 自己动手写编译器、链接器-第七章
- MBProgressHUD
- (七)Spring核心框架 - AOP的起源及介绍
- Microsoft Fakes初探
- iOS8 UIKeyInput protocol
- MyEclipse修改HTML,JSP的默认打开方式
- 自己动手写编译器、链接器-第八章
- nginx-并发模型
- javafX8初探(树形表格)
- VS2010中调用matlab文件,没有找到mclmcr.dll,应用程序未能启动
- EditPlus配置问题
- 自己动手写编译器、链接器-第八章
- pac文件中的proxy地址