开发者

Calling method set as target on UIButton

开发者 https://www.devze.com 2023-01-27 03:58 出处:网络
If开发者_JS百科 I have a UIButton which has a target set, is there a way to call this method without explicitly calling it?

If开发者_JS百科 I have a UIButton which has a target set, is there a way to call this method without explicitly calling it?

For example:

[newViewController.button addTarget:self action:@selector(MyMethod) forControlEvents:UIControlEventTouchUpInside];

I'm then looking to call this method in newViewController but cannot as MyMethod belongs to the parent view. So I really want to be able to say, just call the method/target on the UIButton button. But how can I do this?

Thanks


Just found out how to do this. Was pretty easy, feel like a noob asking now!

[button sendActionsForControlEvents:UIControlEventTouchUpInside];
0

精彩评论

暂无评论...
验证码 换一张
取 消