gpt4 book ai didi

objective-c - 如何读取 IBAction 中的按钮标签?

转载 作者:太空狗 更新时间:2023-10-30 03:56:45 25 4
gpt4 key购买 nike

我有按钮:

...

UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
rightButton.tag = myCustomNumber;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
...

这里是 IBAction:

..
-(IBAction)showDetails:(id)sender{

// here I want to NSLOG button tag

}
...

怎么做?

最佳答案

只需将您的发件人转换到 UIControl

-(IBAction)showDetails:(UIControl *)sender {

// here I want to NSLOG button tag
NSLog(@"%d",sender.tag);

}

关于objective-c - 如何读取 IBAction 中的按钮标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10831328/

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