开发者

touch on window in iphone sdk?

开发者 https://www.devze.com 2023-01-14 00:34 出处:网络
is it possible to handle touchbegin, moved, and ended in UIWindow as it is done in UIView? Is there a tutorial I c开发者_JAVA技巧ould review?Look at Apple\'s documentation for the UIResponder class.A

is it possible to handle touchbegin, moved, and ended in UIWindow as it is done in UIView? Is there a tutorial I c开发者_JAVA技巧ould review?


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.


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]; 
}


Subclass your window from UIWindow

Then implement: touchesBegan,touchesMoved,touchesEnd functions

0

精彩评论

暂无评论...
验证码 换一张
取 消