问问题
618 次
2 回答
1
There's a delightful solution here to finding the first responder by exploiting the responder chain.
Once you know the first responder, it's easy to ask if the current responder chain handles a particular action. You can even find out who'll be handling it, should you wish.
const SEL action = @selector(theActionYouWantToSend);
UIResponder *const currentTarget = [[UIResponder firstResponder] targetForAction: action withSender: self];
const bool actionIsHandled = currentTarget != nil;
于 2015-01-09T16:07:28.380 回答
0
You can check if the responder can respond to the action like this:
[aResponder respondsToSelector:@selector(methodToSend)];
If it can respond, it'll return YES
. Then you know it's safe to call that method
于 2015-01-09T16:00:01.767 回答