简体   繁体   中英

How to pass touch event to another object?

I referenced the apps called "Comic Strip" and "Balloon Stickies Free"

When i add a speech balloon and touch sb or sb's tail, it works. But when i touch tail's around or between sb and sb's tail, it doesn't work. And Photo gets touch and works below the sb

So i tried to use hitTest:withEvent.

It works when i touch rectangle or tailRect first time. But when i touch other place in the object, and i touch rectangle or tailRect again, it doesn't work.

So how to modify this code ? i don't know .. help me please

- (id)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    UIView *hitView = [super hitTest:point withEvent:event];

    if(CGRectContainsPoint(rectangle, currentPt)==YES || CGRectContainsPoint(tailRect, currentPt)==YES)
        return hitView;
    else
        return nil;
}

Try overriding - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event instead.

Or take a look at Ole Begemann's OBShapedButton . Code can easily be modified to work with UIView instead of UIButton.

See this post horizontal scrolling . Using this code you can get all touch events in a single UIWindow class. You have to write some code to pass control appropriately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM