我想给一个字符串值UIButton
标记唯一标识。 我试过这段代码,但它不起作用。将字符串分配给UIButton的标记值
NSString *A;
NSString *B;
NSString *C;
NSString *D;
firstOptionABtn.tag=[A integerValue];
secondOptonBbtn.tag=[B integerValue];
thirdOptionCbtn.tag=[C integerValue];
fourthOptionDbtn.tag=[D integerValue];
- (IBAction)BtnClicked:(UIButton *)sender {
NSLog(@"%ld",(long)sender.tag);
}
我不喜欢这种方式,但它每次都会打印0。我哪里错了? 请帮忙。由于
downvoter为什么downvoting我。的[如何字符串传递作为的UIButton的标签] – Jitendra
可能重复(http://stackoverflow.com/questions/9632040/how-to-pass-a-string-as-a-tag-of-uibutton) –