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);
}

最新更新