How do I set and get UIButtons' tag?

后端 未结 3 919
伪装坚强ぢ
伪装坚强ぢ 2021-01-04 14:22

How do I set a tag for a button programmatically?

I later want to compare to tags for a conclusion

I\'ve tried this

-(IBAction)buttonPressed:         


        
3条回答
  •  有刺的猬
    2021-01-04 14:49

    No need for casting. This should work:

    -(IBAction)buttonPressed:(UIButton*)sender
    {
    NSLog(@"%d", [sender tag]);
    }
    

提交回复
热议问题