我正在向我的 uiactionsheet 动态添加按钮。我最后添加了一个“取消”按钮,但如果我使用方法 setCancelButtonIndex 或手动设置索引,则不会显示“取消”。如果我排除 setCancelButtonIndex 调用,Cancel 就在那里(当然没有突出显示)。有没有我错过的脚注?
UIActionSheet *actionSheet;
actionSheet = [[UIActionSheet alloc] initWithTitle:@"What do you want to do?" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
for (NSString *title in arrayButtons) {
[actionSheet addButtonWithTitle:title];
}
[actionSheet addButtonWithTitle:@"Cancel"];
[actionSheet setCancelButtonIndex:[arrayButtons count]-1];
[actionSheet setDestructiveButtonIndex:0];
[actionSheet showInView:self.view];