ObjectiveC:是可能设置全局按钮(未在类)直接激活全局方法? [英] ObjectiveC:Is possible to set global button(not in the class) to activate global method directly?
本文介绍了ObjectiveC:是可能设置全局按钮(未在类)直接激活全局方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
就像提问时表示。
可以设置全局按钮(未在类)直接激活全局方法?
我困惑的设定目标和行动的一部分。
导入Global.h作废了methodA()
{
* UIButton的按钮= [UIButton的buttonWithType:UIButtonTypeRoundRect];
button.frame = CGRectMake(0,441,100,30);
[按钮addTarget:???动作@选择(的methodB ????)forControlEvent ...]
}无效的methodB()
{
}
//文件结束
解决方案
你所试图做的是建立一个无针对性的行动与响应链的工作。
有关于它的<一读href=\"http://developer.apple.com/library/ios/#DOCUMENTATION/General/Conceptual/Devpedia-CocoaApp/Responder.html\"相对=nofollow> iOS的核心竞争力文档。
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
解决方案
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.
这篇关于ObjectiveC:是可能设置全局按钮(未在类)直接激活全局方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文