是否可以使用
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
Run Code Online (Sandbox Code Playgroud)
在viewcontroller.m文件中?任何教程请?
Vla*_*mir 11
hitTest:withEvent: 方法在UIView类中声明,因此您不能直接在UIViewController子类中使用它.
但是touchesBegan:withEvent:UIResponder中声明了其他触摸跟踪方法,因此可以在UIView和UIViewController子类中实现.
也许另一种解决方法是简单地将UIView子类化,并且在视图控制器的init函数中将视图控制器视图分配给该UIView.
例如.NavPanelViewController.m
- (id)init
theView = [[NavPanelView alloc]init]; // declare theView in your header and in dealloc release
self.view = theView;
Run Code Online (Sandbox Code Playgroud)
然后,您可以覆盖子类中的pointInside方法.
| 归档时间: |
|
| 查看次数: |
12387 次 |
| 最近记录: |