调用设置为 UIButton 上目标的方法
如果我有一个设置了目标的 UIButton,有没有办法在不显式调用它的情况下调用此方法?
例如:
[newViewController.button addTarget:self action:@selector(MyMethod) forControlEvents:UIControlEventTouchUpInside];
然后我希望在 newViewController
中调用此方法,但不能,因为 MyMethod
属于父视图。所以我真的希望能够说,只需调用 UIButton 按钮上的方法/目标即可。但我该怎么做呢?
谢谢
If 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚知道如何做到这一点。很简单,现在感觉像个菜鸟一样问!
Just found out how to do this. Was pretty easy, feel like a noob asking now!