美文网首页
写自定义键盘时touch事件有感

写自定义键盘时touch事件有感

作者: 碧玉小瑕 | 来源:发表于2017-04-13 21:49 被阅读2次

    1,如果在一个view上实现UITouch事件的重写,而如果有view将其拦住的话可能会出问题

    2.如果在view上有button,即便button没有实现事件方法,也会将点击事件吸收,这时候最好用

    -(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event

    方法来拦截。

    -(UIView*)hitTest:(CGPoint)point withEvent:(UIEvent*)event

    {

    for(inti =0; i

    XQKeyboardBtn*button =self.btnArray[i];

    if(CGRectContainsPoint(button.frame, point)) {

    returnself;

    }

    }

    returnself;

    }

    相关文章

      网友评论

          本文标题:写自定义键盘时touch事件有感

          本文链接:https://www.haomeiwen.com/subject/ossiattx.html