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

首頁 > 系統 > iOS > 正文

IOS中的target action控件的實現

2019-10-21 18:45:09
字體:
來源:轉載
供稿:網友

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控件的實現,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!


注:相關教程知識閱讀請移步到IOS開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 尚义县| 洱源县| 桃园县| 江达县| 夹江县| 收藏| 惠水县| 无锡市| 建瓯市| 贞丰县| 舟曲县| 大关县| 呼和浩特市| 清水河县| 宜都市| 永济市| 泸定县| 宜宾市| 双鸭山市| 河津市| 舒城县| 普宁市| 广西| 桂阳县| 通海县| 灵山县| 梧州市| 莎车县| 中卫市| 营山县| 偏关县| 邢台市| 彰化市| 宜丰县| 苏尼特左旗| 香港| 景宁| 修水县| 新化县| 彰武县| 道孚县|