我已经子类UIActionSheet
,并且在-init
方法中,我必须在调用超级init
(无法传递var_args)后单独添加按钮。UIActionSheet addButtonWithTitle:不以正确的顺序添加按钮
现在,它看起来像这样:
if (self = [super initWithTitle:title delegate:self cancelButtonTitle:cancel destructiveButtonTile:destroy otherButtonTitles:firstButton,nil]) {
if (firstButton) {
id buttonTitle;
va_list argList;
va_start(argList, firstButtton);
while (buttonTitle = va_arg(argList, id)) {
[self addButtonWithTitle:buttonTitle]
}
va_end(argList);
}
}
return self;
然而,我在这种情况下,具体的使用有没有破坏性的按钮,一个取消按钮和其他四个按钮。当它出现时,顺序是全部关闭,显示为
Button1的
取消
Button2的
将Button3
像他们只是添加到列表中,这是有道理的结束;但是,我不想看起来像这样;那么我该怎么做?实际上,是否有任何方法可以正确地子类别UIActionSheet
,并使其工作?
啊,这使得它更容易。我以为那些是只读的 – 2009-08-11 19:11:49
很好的答案,但柜台实际上是不必要的。 addButtonWithTitle:返回它添加的索引。 – 2010-07-21 01:24:03