Is it possible to use:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
in viewcontroller.m file?
hitTest:withEvent:
method is declared in UIView class so you it can't be used in UIViewController subclasses directly.
But other touch-tracking methods such as touchesBegan:withEvent:
etc are declared in UIResponder and so can be implemented in both UIView and UIViewController subclasses
Perhaps an alternative workaround is simply to subclass UIView , and in your init function of view controller assign the view controllers view to that UIView.
Eg. NavPanelViewController.m
- (id)init
theView = [[NavPanelView alloc]init]; // declare theView in your header and in dealloc release
self.view = theView;
Then you can override the pointInside method in your subclass.
-loadView
. The reason being to avoid prematurely loading the view.
Commented
Jan 9, 2014 at 17:44
You can always define a specific delegate for handling the hitTest relevant info. In the hitTest:withEvent:
in your UIView class's .m (implementation) file call the delegate's method, passing all your relevant info to the delegate to handle. Declare your ViewController class to implement the delegate like this:
@implementation MyViewController: UIViewController <HitTestDelegate>
This way, the actual implementation of the logic following user's tap will be in the MyViewController class.