SEG
SEG

Reputation: 1715

How do I create a "delete" actionsheet in xcode?

How do I create a delete confirmation like the one shown below?

Upvotes: 0

Views: 1526

Answers (4)

Krishnabhadra
Krishnabhadra

Reputation: 34285

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
    }
}

Upvotes: 2

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31720

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

How can I create a big, red UIButton with the iPhone SDK?

Upvotes: 1

Moshe
Moshe

Reputation: 58097

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];

Upvotes: 2

Jason
Jason

Reputation: 11822

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.

Upvotes: 0

Related Questions