.... Call to webservice
NSArray *someValues = [results valueForKey:@"someKey"];
[button setTitle:[NSString stringWithFormat:@"%@", [someValues objectAtIndex:i]] forState:UIControlStateNormal];
} // end
-(void)btnPressed:(id)sender
{
UIButton *button = sender;
button.currentTitle; // Title comes back just fine
}
I want to be able to add more parameters so I can get them back on the click method. So example
button.someParam = @"My name"
...
// once clicked
UIButton *button = sender;
button.someParam // gets back "My Name"
目前我可以设置一个自定义标题并恢复正常。我想添加更多值以与我的按钮一起传递。这可能吗?这些值正在动态返回。我知道我可以设置标签 #,但这无助于我从我尝试过的内容中获取自定义值。
最佳答案
您想将属性添加到 UIButton
。
一种方法是创建一个 UIButton
子类并在其中添加属性。然后使用该子类代替常规的 UIButton
。
关于ios - 为 UIButton 设置多个自定义参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30113706/