国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

IOS中的target action控件的實現

2020-07-26 02:44:04
字體:
來源:轉載
供稿:網友

IOS中的target action控件的實現

實現代碼:

#import <Foundation/Foundation.h>   @interface Sample : NSObject {    SEL action;   id target;    } @property SEL action; @property (assign) id target;  -(void)addTarget:(id) t action:(SEL) s; -(void)sample_dosomthing;  @end 
#import "Sample.h"   @implementation Sample  @synthesize action; @synthesize target;   -(void)dealloc{   target = nil;   [super dealloc]; }  -(void)addTarget:(id) t action:(SEL) s{   self.action = s;   self.target = t; }   -(void)sample_dosomthing{      [self.target performSelector:self.action]; }  @end 

這是一個例子,在一個UIViewController里面

-(void)control_dosomthing{   NSLog(@"control_dosomthing"); }  - (void)viewDidLoad {   [super viewDidLoad];      Sample *sample1 = [Sample new];   [sample1 addTarget:self action:@selector(control_dosomthing)]; } 

以上就是IOS中的target action控件的實現,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巢湖市| 阿合奇县| 锡林浩特市| 湖南省| 武夷山市| 邢台县| 东阳市| 嘉鱼县| 东丰县| 延川县| 醴陵市| 三亚市| 北碚区| 新营市| 乐都县| 开鲁县| 宁国市| 大厂| 建昌县| 古田县| 平顶山市| 肥东县| 城固县| 阳城县| 枣庄市| 安仁县| 怀远县| 崇阳县| 工布江达县| 依安县| 梨树县| 大丰市| 蒙山县| 麻城市| 睢宁县| 高邑县| 宜城市| 星座| 蚌埠市| 巨野县| 简阳市|