gpt4 book ai didi

iphone - 点击 UIButton 时如何发送对象作为参数?

转载 作者:行者123 更新时间:2023-12-03 19:29:42 26 4
gpt4 key购买 nike

我的 UIViewController 中有以下代码 -

[flipButton addTarget:self.navigationController.delegate action:@selector(changeModeAction:) forControlEvents:UIControlEventTouchUpInside];

如您所见,它调用导航 Controller 委托(delegate)内的方法。如何正确地将对象传递给此方法?

最佳答案

您可以使用图层属性。添加您想要作为图层字典中的值传递的对象。

[[btn layer] setValue:yourObj forKey:@"yourKey"];

可以通过按钮操作函数访问此 yourObj:

-(void)btnClicked:(id)sender
{
yourObj = [[sender layer] valueForKey:@"yourKey"];
}

使用此方法,您只需通过使用不同的键在字典中添加新对象即可将多个值传递给按钮函数。

关于iphone - 点击 UIButton 时如何发送对象作为参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5397230/

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