Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(UIView *)hitTest in viewcontroller?

Tags:

iphone

ipad

Is it possible to use

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

in viewcontroller.m file? any tutorial pls?

like image 599
senthilM Avatar asked Sep 08 '10 08:09

senthilM


People also ask

How hitTest works?

In hit-testing, a window calls hitTest:withEvent: on the top-most view of the view hierarchy; this method proceeds by recursively calling pointInside:withEvent: on each view in the view hierarchy that returns YES, proceeding down the hierarchy until it finds the subview within whose bounds the touch took place.

What is the difference between UIView and UIViewController?

They are separate classes: UIView is a class that represents the screen of the device of everything that is visible to the viewer, while UIViewController is a class that controls an instance of UIView, and handles all of the logic and code behind that view.


1 Answers

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

like image 195
Vladimir Avatar answered Sep 19 '22 15:09

Vladimir