首页 > 代码库 > UIButton 点击事件传参数

UIButton 点击事件传参数

UIButton *btn = // create the button 
objc_setAssociatedObject(btn, "firstObject", obj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
[btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];  

- (void)click:(UIButton *)sender  
{  
    id first = objc_getAssociatedObject(btn, "firstObject"); //取参
}  

 

UIButton 点击事件传参数