开发者

iPhone: touches on UIViewController

开发者 https://www.devze.com 2023-01-11 18:45 出处:网络
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 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 proces开发者_如何学编程s 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.

0

精彩评论

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