在底部的UIActionSheet中放置取消按钮

Aru*_*run 5 cocoa-touch uiactionsheet ios

在UIActionSheet中,我有一个uitableview和取消按钮.默认情况下,取消按钮显示在顶部.我想让它在tableview后显示在底部.我怎么做?

小智 6

这对我有用:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"SomeTitle" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil, nil];
[actionSheet addButtonWithTitle:@"Some Action"];        
[actionSheet addButtonWithTitle:@"Cancel"];
actionSheet.cancelButtonIndex = actionSheet.numberOfButtons -1;
Run Code Online (Sandbox Code Playgroud)


nzs*_*nzs 0

我尝试了这个,取消按钮位于底部:

menu = [[UIActionSheet alloc] initWithTitle:@"Actionsheet"
                                                  delegate:self
                                         cancelButtonTitle:@"Cancel"
                                    destructiveButtonTitle:@"destructive"
                                         otherButtonTitles:@"other1", nil];
menu.actionSheetStyle = UIActionSheetStyleDefault;
[menu addButtonWithTitle:@"Cancel"];
Run Code Online (Sandbox Code Playgroud)

默认情况下“取消”按钮是隐藏的,添加“取消”就会显示它。

但是:如果您的操作表上有其他 gui 元素,您必须

option1)放置这些按钮以隐藏其他按钮(为您的 gui 元素留出空间)。这是一个调整,但可以在某些情况下工作或者

选项2)您必须手动将按钮添加到操作表中

Actionsheet 的内置按钮无法自由对齐到底部,因为此内置 gui 元素的目的不同。

请参阅:将 UIPickerView 添加到 UIActionSheet (底部按钮)