tag
中是否还有其他属性UIButton
,可用于存储NSString
?
我知道tag
是一个int,所以我无法存储@"myValue"
。我想知道是否有其他方法可以做到这一点。
答案 0 :(得分:3)
不,没有任何与tag
相似的NSString。
请注意,如果您只想要一个描述性标记,则枚举可能很有用。
enum ButtonTypes {
ButtonTypeUnknown,
ButtonTypeOK,
ButtonTypeFoo,
ButtonTypeBar,
// etc...
};
然后......
switch (mybutton.tag) {
case ButtonTypeFoo:
// handle this button type
break;
case ButtonTypeBar:
// handle this button type
break;
default:
break;
}
答案 1 :(得分:2)
我最终继承了UIButton并添加了我想要的属性。这很容易。