gpt4 book ai didi

ios - 在 iPhone 中获取按钮标签值

转载 作者:可可西里 更新时间:2023-11-01 05:01:25 27 4
gpt4 key购买 nike

动态制作了20个Button,得到了所有Button的tag值。

但我需要知道如何使用该标签值。

我需要每个按下标签值的按钮的信息。
那么,我该如何使用这些标签值呢?

最佳答案

您需要设置每个按钮的目标 Action 。

[button setTarget:self action:@selector(someMethod:) forControlEvents:UIControlEventTouchUpInside];

然后像这样实现someMethod::

- (void)someMethod:(UIButton *)sender {
if (sender.tag == 1) {
// do action for button with tag 1
} else if (sender.tag == 2) {
// do action for button with tag 2
} // ... and so on
}

关于ios - 在 iPhone 中获取按钮标签值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7282809/

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