在 UIActionSheet 我有一个 uitableview 和取消按钮。默认情况下,取消按钮出现在顶部。我想让它出现在 tableview 之后的底部。我怎么做?
问问题
3744 次
3 回答
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;
于 2014-06-29T16:19:55.160 回答
0
我试过了,取消按钮在底部:
menu = [[UIActionSheet alloc] initWithTitle:@"Actionsheet"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"destructive"
otherButtonTitles:@"other1", nil];
menu.actionSheetStyle = UIActionSheetStyleDefault;
[menu addButtonWithTitle:@"Cancel"];
默认情况下,取消按钮是隐藏的,添加取消将显示它。
但是:如果您的操作表上有其他 gui 元素,则必须
option1)定位那些隐藏其他按钮(为您的gui元素留出空间)。它是一个调整,但可以在某些情况下工作或
选项2)您必须手动将按钮添加到操作表
Actionsheet 的内置按钮不能自由对齐到底部,因为此内置 gui 元素的用途不同。
于 2013-04-22T06:51:01.010 回答
0
斯威夫特的例子:
func presentMyActionSheetIOS7() {
let actionSheet: UIActionSheet = UIActionSheet(title: "What do you want to do?", delegate: self, cancelButtonTitle: nil, destructiveButtonTitle: nil)
actionSheet.addButtonWithTitle("Change Transparency")
actionSheet.addButtonWithTitle("Hide Photo")
actionSheet.addButtonWithTitle("Cancel")
actionSheet.cancelButtonIndex = actionSheet.numberOfButtons - 1
actionSheet.showInView(self.view)
}
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
switch buttonIndex {
case 0:
println("Change Transparency")
case 1:
println("Hide Photo")
case 2:
println("Cancel")
default:
println("Default")
}
}
于 2015-03-12T19:39:45.680 回答