How do I create a “delete” actionsheet in xcode?
-
27-10-2019 - |
题
How do I create a delete confirmation like the one shown below?
解决方案
If you want the same as shown in photo along with other button use the below UIActionSheet blog tutorial and if you want just standalone button follow the below SO post
其他提示
That is an instance of a UIActionSheet. The red button is called the "destructive button" and the black button, the "cancel button".
Here is a demo:
UIActionSheet *actSheet = [[UIActionSheet alloc] initWithTitle:@"The text to show on top. (Like the message about wiping the phone.)"delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete everything" otherButtonTitles:nil];
[actSheet ShowFromToolbar:self.toolbar];
[actSheet release];
You need to use UIActionSheet.
You can create an ActionSheet like this
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@”YOUR_ACTION_SHEET_TITLE”
delegate:self
cancelButtonTitle:@”Cancel”
destructiveButtonTitle:@”Erase Iphone”
otherButtonTitles:nil];
[actionSheet showInView:self.view];
[actionSheet release];//If you are not using ARC
You need to implement UIActionSheetDelegate
method
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0){
//do your action
}else if(buttonIndex == 1){
// do your other action
}
}
Use InterfaceBuilder (or the equivalent editors in xCode4) to create the view. Write your view controller. Then animate the view to slide in from below using Core Animation.
不隶属于 StackOverflow