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;
ただし、この場合には、私の具体的な使用には破壊的なボタン、キャンセルボタン、および他の4つのボタンがありません。それが現れた場合、順序は、彼らは単に理にかなって、リストの末尾に追加された同様
Button2の
ボタン3
をキャンセルボタン1
として現れて、すべてをオフになっています。しかし、私はこのように見えません。私は何をしますか?実際にUIActionSheet
を正しくサブクラス化してこの作業を行う方法はありますか?
ああ、それは簡単です。私はそれらが読み取り専用だと思った –
良い答えが、実際には不要です。 addButtonWithTitle:追加されたインデックスも返します。 –