Lorenzo Ang
Lorenzo Ang

Reputation: 1318

Does anyone know the name of this UIObject? (Picture inside)

I'm trying to add something like this to my program but idk what it's called. enter image description here

I'm talking about the buttons that pop up "Photo Library" "Take Photo or Video" "Cancel"

Upvotes: 0

Views: 63

Answers (2)

Jonathan Müller
Jonathan Müller

Reputation: 66

It's a UIAlertController with style UIAlertControllerStyleActionSheet. You use it like this:

UIAlertController *aC = [UIAlertController alertControllerWithTitle:@"Title"
                                                            message:@"Message"
                                                     preferredStyle:UIAlertControllerStyleActionSheet];

[aC addAction:[UIAlertAction actionWithTitle:@"Button 1"
                                       // Style can be default, destructive or cancel
                                       style:UIAlertActionStyleDefault
                                     handler:^(UIAlertAction *action) {
    // handler
}]];

// Add more actions (buttons) here if needed

// Assuming you're in your view controller,
// present the alert view controller like this:
[self presentViewController:aC animated:YES completion:nil];

Upvotes: 1

Earl Grey
Earl Grey

Reputation: 7466

UIActionSheet class from Cocoa touch.

Upvotes: 1

Related Questions