Re: Cocoa alternative for method aliasing?
Re: Cocoa alternative for method aliasing?
- Subject: Re: Cocoa alternative for method aliasing?
- From: Matt Neuburg <email@hidden>
- Date: Tue, 29 Mar 2011 12:25:03 -0700
On Tue, 29 Mar 2011 11:20:31 -0700, Lou Zell <email@hidden> said:
>I have a subclass of UIButton, call it MyButton, that I would like to
>function as a vanilla UIButton but also pass touch events to the next
>responder (I'm interested in eventually getting the events in
>UIViewController). I can do something like this in MyButton:
>
>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
>{
> [[self nextResponder] touchesBegan:touches withEvent:event];
>}
Don't do that. The way to pass touches up the responder chain is by calling super. This will do exactly what you're after, I think.
However, as already implied, you might be better off with a different architecture. It isn't at all clear why you'd do what you're describing. Let the button act as a button. If you need further information about what's going on, consider a gesture recognizer, perhaps, or just use the button's control events. In any case there should be no need to interfere at the very low level of the touches... responder methods. There are *many* ways to interfere with aspects of touch delivery; they are quite interesting, but be careful or you'll break something.
m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden