ObjectiveC:Is possible to set global button(not in

2019-08-17 17:57发布

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条回答
狗以群分
2楼-- · 2019-08-17 18:22

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.

查看更多
登录 后发表回答