iOS 如何传递方法

2016-09-08  本文已影响67人  屈涯

如果想将方法作为参数传递,该如何操作

- (void)viewDidLoad {

[superviewDidLoad];

// Do any additional setup after loading the view.

[selfbuttonAction:@selector(testAction)];

}

- (void)buttonAction:(SEL)button{

self.button= [[UIButtonalloc]initWithFrame:CGRectMake(100,100,100,100)];

self.button.backgroundColor= [UIColorredColor];

self.button.showsTouchWhenHighlighted=YES;

[self.buttonaddTarget:selfaction:buttonforControlEvents:6];

[self.viewaddSubview:self.button];

}

- (void)testAction{

[BassViewControllerbuttonAction];

}

上一篇下一篇

猜你喜欢

热点阅读