search

Home  >  Q&A  >  body text

objective-c - Button传值怎么传?


我想把row传到plusEvent方法里 不知道怎么做 没百度到

伊谢尔伦伊谢尔伦2757 days ago466

reply all(2)I'll reply

  • PHPz

    PHPz2017-05-02 09:26:03

    1. The simplest way is to use the button tag to pass the value. But this is not a recommended approach. . And only int type can be passed.
    2. You can customize a button to inherit UIButton and use data as an attribute. (Recommended)
    3. You can add a category. Use runtime Associative technology to force the addition of a data attribute. (Key recommendation)
    Associative technology, you can see the Associative node demo in this article: click to enter

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-02 09:26:03

    plusBtn.tag = indexPath.row;
    Then sender.tag

    in plusEvent:

    reply
    0
  • Cancelreply