我想給一個字符串值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) –