1

=== コード ===

UIActionSheet* as = // UIActionSheet alloc one

[as addButtonWithTitle:@"Button1"];
[as addButtonWithTitle:@"Button2"];
[as addButtonWithTitle:@"Button3"]; // this button will be set destructive
[as addButtonWithTitle:@"Button4"];

[as addButtonWithTitle:@"ButtonMore1"];
[as addButtonWithTitle:@"ButtonMore2"];
[as addButtonWithTitle:@"ButtonMore3"];

as.destructiveButtonIndex = 2;

=== バグ ===

私のアプリは横向きモードで実行され、5 つ以上のボタンを含むアクションシートがフルスクリーン スタイルで表示されるため、ユーザーは上下にスクロールして必要な特別なボタンを見つけることができます。

次に、破壊的なボタン(「Button3」)が一番上に持ち上げられます.Appleは、アクションシートをスクロールするときに誤って破壊的なボタンをタップすることを望んでいないと思いますが、これにより、buttonIndexとbuttonTitleが間違った順序になります:

NSLog(@"index = %d title = %@",buttonIndex,[actionSheet buttonTitleAtIndex:buttonIndex]);

出力は、本来あるべきものではありません。しかし、破壊的なボタンを設定しないと、期待どおりに機能します。

4

0 に答える 0