我们在UIScrollView中经常要使用UITextField或者别的文本编辑,通常我们需要点击空白处来隐藏键盘,这时你会发现在- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 这个方法中不能响应事件,这是因为UIScrollView截取了touch事件,我们需要声明个UIScrollView的Category,在里面重写
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
}
通过super来把touch事件给传回父View。我们就可以在父View中处理响应事件了。
2624

被折叠的 条评论
为什么被折叠?



