ObjectiveC:Is possible to set global button(not in the class) to activate global method directly?

走远了吗. 提交于 2019-12-13 06:51:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!