大佬教程收集整理的这篇文章主要介绍了uitextfield – 使用IOS 8编辑时,键盘会间歇性地消失,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是一些相关的代码.所有这些都是在用户点击文本字段外时隐藏键盘.我的UIViews是我的Touchview类的子类,它接收所有触摸:
TouchView.h:
@protocol TouchViewDelegate <NSObject> -(UIView *) handleTouches:(NSSet *)touches withEvent:(UIEvent *)event inView:(UIView *) view; @end @interface TouchView : UIScrollView @property (nonatomic,strong) id <TouchViewDelegate> touchDelegate; @end
TouchView.m:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView * touchedView = [super hitTest:point withEvent:event]; NSSet* touches = [event allTouches]; [self.touchDelegate handleTouches:touches withEvent:event inView:touchedView]; return touchedView;
}
我将主视图配置为Touchview并将其包含在viewDidLoad中:
- (void)viewDidLoad { [super viewDidLoad]; HMWTouchView * touchView = (HMWTouchView*) self.view; touchView.touchDelegate = self; ... }
这是委托方法的实现:
-(UIView *) handleTouches:(NSSet *)touches withEvent:(UIEvent *)event inView:(UIView *) hitView { if (![hitView isKindOfClass:[UIButton class]]) { [[UIResponder firstResponder] resignFirstResponder]; } return self.view; }
这看起来至少是IOS 8如何响应命中的变化.
以上是大佬教程为你收集整理的uitextfield – 使用IOS 8编辑时,键盘会间歇性地消失全部内容,希望文章能够帮你解决uitextfield – 使用IOS 8编辑时,键盘会间歇性地消失所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。