===代码===
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”)将被提升到顶部,我猜苹果不希望人们在滚动动作表时点击错误的破坏性按钮,但这会使buttonIndex和buttonTitle按错误的顺序:
NSLog(@"index = %d title = %@",buttonIndex,[actionSheet buttonTitleAtIndex:buttonIndex]);
输出不完全是他们应该的。 但如果我没有设置任何破坏性按钮,那么它会按预期工作。