Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在UIButton选择器中发送一个字符串作为参数。采用全局字符串对我不起作用。按钮是自定义类型。我试过 :
UIButton
btn.titleLabel.text = str;
并在选择器中访问它,但收到nil。
你会这样
[b addTarget:self action:@selector(buttonTap:)forControlEvents:UIControlEventTouchUpInside]; -(IBAction)buttonTap:(id)sender { UIButton *b = (UIButton*)sender; NSLog(@"%@",b.titleLabel.text); }