【问题标题】:How to pass method parameters through addTarget如何通过 addTarget 传递方法参数
【发布时间】:2014-06-05 12:14:25
【问题描述】:

我正在向UISwitch 添加目标,我想同时传递发件人 (UISwitch) 和对象 (NSIndexPath)。

我不确定这个的语法,如果有人能指出我正确的方向,那就太好了

[certificateSwitch addTarget:self action:@selector(certificateSwitcher:withIndexPath:) forControlEvents:UIControlEventValueChanged];

方法:

- (void)certificateSwitcher:(UISwitch *)sender withIndexPath:(NSIndexPath *)indexpath

在有人说将行号作为UISwitch's 标签属性之前,这不是一个选项,我还有一些其他的东西依赖于UISwitch 的标签

谢谢

【问题讨论】:

标签: ios methods parameters target


【解决方案1】:

不,您不能传递 your_Own 值。

您应该使用tag 属性或者您可以使用subclassing the UISwitch

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-15
    • 2016-02-03
    • 2015-07-06
    • 1970-01-01
    • 2016-02-24
    • 2016-04-26
    • 1970-01-01
    相关资源
    最近更新 更多