views:

38

answers:

3

is it possible to handle touchbegin, moved, and ended in UIWindow as it is done in UIView? Is there a tutorial I could review?

+3  A: 

Look at Apple's documentation for the UIResponder class. A UIWindow descends from the UIResponder class, thus can optionally handle all UI events, including touch events, for contained UIViews.

hotpaw2
any tutorial please?
Mikhail Naimy
+1  A: 

Subclass your window from UIWindow

Then implement: touchesBegan,touchesMoved,touchesEnd functions

Meir Assayag
will you explain in detail...i tried ..it did not work...
Mikhail Naimy
+1  A: 

Pay attention that if any View added to the window capture the event and doesn't forward it, the window object will never receive it. UIScrollView typically does that. In that case, you also need to subclass the blocking view to forward the event like this for example :

in a UIScrollView subclass :

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    if (!self.dragging) {
        [self.nextResponder touchesEnded: touches withEvent:event]; 
    }       
    [super touchesEnded: touches withEvent: event]; 
}
VdesmedT
UIscrollview subclass means , please give explaination.....can i handle directly touch event in appdelegate.m file for UIwindow
Mikhail Naimy
subclassing UIScrollView means create a class that inherit from UIScrollView like@interface myScrollView : UIScrollView {}@end
VdesmedT