IOS中的target action控件的實(shí)現(xiàn)
IOS中的target action控件的實(shí)現(xiàn)
實(shí)現(xiàn)代碼:
#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
這是一個(gè)例子,在一個(gè)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控件的實(shí)現(xiàn),如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
iOS界面跳轉(zhuǎn)時(shí)導(dǎo)航欄和tabBar的隱藏與顯示功能
這篇文章主要介紹了iOS界面跳轉(zhuǎn)時(shí)導(dǎo)航欄和tabBar的隱藏與顯示功能,需要的朋友可以參考下2017-02-02
iOS開發(fā)Quick Actions創(chuàng)建桌面Icon快捷方式
在本文里我們給大家分享了關(guān)于iOS開發(fā)Quick Actions創(chuàng)建桌面Icon快捷方式的相關(guān)知識(shí)點(diǎn)內(nèi)容,需要的讀者們可以參考下。2019-05-05
iOS 報(bào)clang: error: no input files錯(cuò)誤的解決方法
這篇文章主要給大家介紹了關(guān)于iOS報(bào)clang: error: no input files錯(cuò)誤的解決方法,文中通過(guò)圖文介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2018-01-01
解決ios h5 input輸入框被輸入法彈出一塊區(qū)域的問(wèn)題
今天小編就為大家分享一篇解決ios h5 input輸入框被輸入法彈出一塊區(qū)域的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-08-08
iOS實(shí)現(xiàn)底部彈出PopupWindow效果 iOS改變背景透明效果
這篇文章主要為大家詳細(xì)介紹了iOS實(shí)現(xiàn)底部彈出PopupWindow效果,iOS改變背景透明效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07
混合棧跳轉(zhuǎn)導(dǎo)致Flutter頁(yè)面事件卡死問(wèn)題解決
這篇文章主要為大家介紹了混合棧跳轉(zhuǎn)導(dǎo)致Flutter頁(yè)面事件卡死問(wèn)題解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08

