点击按钮
时,任何人都可以帮助我带来此视图答案 0 :(得分:2)
NSString *actionSheetTitle = @"Title You want to give"; //Action Sheet Title
NSString *destructiveTitle = nil; //Action Sheet Button Titles
NSString *firstButtonTitle = @"Delete Drafts"; //Action Sheet 1st Button Title
NSString *secondButtonTitle = @"Save Drafts"; //Action Sheet 2nd Button Title
NSString *cancelTitle = @"Cancel"; //Action Sheet Cancel Button Title
UIActionSheet *myActionSheet = [[UIActionSheet alloc]
initWithTitle:actionSheetTitle
delegate:self
cancelButtonTitle:cancelTitle
destructiveButtonTitle:destructiveTitle
otherButtonTitles:firstButtonTitle,secondButtonTitle, nil];
[myActionSheet showInView:self.view.parentViewController.view];
答案 1 :(得分:0)
UIActionSheet *act = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete Draft" otherButtonTitles:@"Save Draft", nil];
[act showInView:self.view];
来自班级参考:
cancelButtonTitle :取消按钮的标题。此按钮会自动添加到操作表中,并分配一个适当的索引,该索引可从cancelButtonIndex属性中获得。此按钮显示为黑色,表示它代表取消操作。如果您不想要取消按钮或在iPad上显示操作表,请指定nil。
destructiveButtonTitle :破坏性按钮的标题。此按钮会自动添加到操作表中,并分配适当的索引,该索引可从destructiveButtonIndex属性中获得。此按钮显示为红色,表示它表示破坏性行为。如果您不想要破坏性按钮,请指定nil。
我会使用破坏性按钮进行删除,因为它将为红色。然后是黑色下方的取消按钮。
使用此方法为每个按钮操作您需要的任何操作:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex.