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如何响应命中的变化.

解决方法

已在iOS 8.0.2中修复,不再需要.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...