问题
Just like the question said. Is possible to set global button(not in the class) to activate global method directly? I confused on setting target and action part.
import "Global.h"
void methodA()
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundRect];
button.frame = CGRectMake(0,441,100,30);
[button addTarget:??? action@selector(methodB????) forControlEvent...];
}
void methodB()
{
}
//end of file
回答1:
What you are trying to do is set up a nil-targeted action that works with the Responder Chain.
Have a read about it in the iOS Core Competencies documentation.
来源:https://stackoverflow.com/questions/6518315/objectivecis-possible-to-set-global-buttonnot-in-the-class-to-activate-global