Target-Action设计模式

含义:

当某个事件发生时,调用某个对象的某个方法

一般情况下,对象就是target,方法就是action

target是controller,action是action

使用方法:

1,创建按钮

2,在controller.h文件中声明action

3,在controller.m文件中实现action

3,给button控件关联action

-(void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

 

此后,当控件发生了controlEvents事件后就会去找到action,执行action代码

posted @ 2014-08-06 14:37  迷茫的程序小生  阅读(286)  评论(0编辑  收藏  举报