1,如果视图是从nib中加载的,我们应该首先实现initWithCode:因为nib中的对象实例将存储为归档对象。(某一个view设置为自定义的子view)

 hitTest代码范例:

  1. - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
  2.     for (UIView *tmpView in self.subviews )
  3.     {
  4.         if(tmpView.userInteractionEnabled && [tmpView isMemberOfClass:[UIButton class]])
  5.         {
  6.             if (CGRectContainsPoint(tmpView.frame,point)) {
  7.                 return tmpView;
  8.             }
  9.         }
  10.     }
  11.     return nil;
  12. }
 

相关文章:

  • 2021-12-19
  • 2021-11-19
  • 2021-07-15
  • 2021-05-02
  • 2022-01-08
  • 2021-09-27
  • 2021-09-01
  • 2021-12-13
猜你喜欢
  • 2022-02-18
  • 2022-12-23
  • 2022-01-23
  • 2021-12-01
  • 2021-12-03
  • 2021-11-30
相关资源
相似解决方案