简体   繁体   中英

iPhone: touches on UIViewController

I have a UIViewController, on top I put an UIImageView, then a UIScrollView.

I can process touches on the UIScrollView just fine, however I want to process certain touches on the UIViewController.

I only need touches on the UIScrollView that are held for 5 seconds (This part works fine). Anything less than that I want to pass to the UIViewController.

On the UISCrollView I call this:

- (void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event
{
// some custom code to process a specific touch.

// all other touches
    [super touchesBegan: touches withEvent: event];
}

Is there a way to pass touches from the UIScrollView to the bottom UIViewController, or do I have to pass a references to the UIViewController into the UIScrollView?

Solved!

Needed to add:

[self.nextResponder touchesEnded: touches withEvent:event]; 

to the top most controller.

Thank you to myself!

touchesBegan description in the Apple Documentation tells:

To forward the message to the next responder, send the message to super (the superclass implementation); do not send the message directly to the next responder. For example,

[super touchesBegan:touches withEvent:event];

If you override this method without calling super (a common use pattern), you must also override the other methods for handling touch events, if only as stub (empty) implementations.

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