gpt4 book ai didi

ios - 来自另一个 Controller 的访问方法

转载 作者:行者123 更新时间:2023-11-29 12:12:25 25 4
gpt4 key购买 nike

我在名为“Remotecontroller”的 Controller 中有一个按钮操作功能。这是方法:

-(IBAction)startDiscover:(id)sender{.....}

我有另一个名为“iptvViewcontroller”的 Controller 。单击按钮时,我需要在此“iptvViewcontroller”中调用上述方法。这是我的按钮点击功能:

btnRefresh3 = [UIButton buttonWithType:UIButtonTypeCustom];
btnRefresh3.frame = CGRectMake(0, 0, 25, 20);
[btnRefresh3 addTarget:self action:@selector(startDiscover:)
[arrLeftBarItems addObject:barButtonItem3];

请有人帮助我让它工作。

最佳答案

通过创建和使用自定义委托(delegate),您可以实现该功能。

Objective-C 委托(delegate)是已分配给另一个对象的委托(delegate)属性的对象。

有关详细信息以及如何创建和使用自定义委托(delegate),请参阅下面的链接。

1. How do I create delegates in Objective-C?

2。 How to use custom delegates in Objective-C

关于ios - 来自另一个 Controller 的访问方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33030806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com