Create action when I click on a button than UIAlertcontroller

mimpami

i Create two buttons of UIAlertcontroller:

One Button - "OpenCamera"
Two button - "OpenGallery"

I just can not understand how I create action when I click on one of them.

- (IBAction)takePic:(id)sender {


UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
                                                               message:nil
                                                        preferredStyle:UIAlertControllerStyleActionSheet]; // 1
UIAlertAction *openCamrea = [UIAlertAction actionWithTitle:@"open camrea"
                                                      style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                                                      }];
UIAlertAction *openGallery = [UIAlertAction actionWithTitle:@"open gallery"
                                                       style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                                                       }];

[alert addAction:openCamrea];
[alert addAction:openGallery];

[self presentViewController:alert animated:YES completion:nil];
}
Joseph Lord

The handler is the block to be executed on the selection of the item.

UIAlertAction *openGallery = [UIAlertAction
    actionWithTitle:@"open gallery"
    style:UIAlertActionStyleDefault
    handler:^(UIAlertAction * action) {
        // Code to run when the open gallery option is pressed.
    }];

BTW I think the long unbroken lines in the question really don't help as they effectively hide the key parameter.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Create action when I click on a button than UIAlertcontroller

From Dev

UIAlertController on button click

From Dev

UIAlertController on button click

From Dev

How to create a new window when I click a button in QT?

From Dev

Call custom controller action from view when I click on a button Rails

From Dev

Android TV how to change detailsFragment data when I click action button?

From Dev

detecting a click on action bar back button -(OnOptionsItemSelected not calling when click on action bar back button)

From Dev

How do I decide whether to create a new window when i Click on a button

From Dev

I want to create combo box when i click a button each time

From Dev

Trying to create imageView when click the button

From Dev

How to create html code when click button?

From Dev

How will i create a loop inside a button click

From Dev

Navigate to ViewController from UIAlertController button click

From Dev

Angularjs action on click of button

From Dev

trigger AJAX action when click on button inside dropdown without closing it

From Dev

Submit button message not fired with script when action click is submit

From Dev

trigger AJAX action when click on button inside dropdown without closing it

From Dev

How to perform action when user click on myLocation button in Objective C?

From Dev

How can I make Floating Action Button rotate on every click

From Dev

How can I realize a swipe action via a button click in Android?

From Dev

display a dialog when i click a button

From Dev

jQuery modal will not display when I click button

From Dev

when I click on the button the app crashes

From Dev

Intent error when I click the button - why?

From Dev

when I click on the button the app crashes

From Dev

display a dialog when i click a button

From Dev

When I click the button to open this activity it closes

From Dev

When I try to click on the button it is not working

From Dev

application stops when I click on button

Related Related

  1. 1

    Create action when I click on a button than UIAlertcontroller

  2. 2

    UIAlertController on button click

  3. 3

    UIAlertController on button click

  4. 4

    How to create a new window when I click a button in QT?

  5. 5

    Call custom controller action from view when I click on a button Rails

  6. 6

    Android TV how to change detailsFragment data when I click action button?

  7. 7

    detecting a click on action bar back button -(OnOptionsItemSelected not calling when click on action bar back button)

  8. 8

    How do I decide whether to create a new window when i Click on a button

  9. 9

    I want to create combo box when i click a button each time

  10. 10

    Trying to create imageView when click the button

  11. 11

    How to create html code when click button?

  12. 12

    How will i create a loop inside a button click

  13. 13

    Navigate to ViewController from UIAlertController button click

  14. 14

    Angularjs action on click of button

  15. 15

    trigger AJAX action when click on button inside dropdown without closing it

  16. 16

    Submit button message not fired with script when action click is submit

  17. 17

    trigger AJAX action when click on button inside dropdown without closing it

  18. 18

    How to perform action when user click on myLocation button in Objective C?

  19. 19

    How can I make Floating Action Button rotate on every click

  20. 20

    How can I realize a swipe action via a button click in Android?

  21. 21

    display a dialog when i click a button

  22. 22

    jQuery modal will not display when I click button

  23. 23

    when I click on the button the app crashes

  24. 24

    Intent error when I click the button - why?

  25. 25

    when I click on the button the app crashes

  26. 26

    display a dialog when i click a button

  27. 27

    When I click the button to open this activity it closes

  28. 28

    When I try to click on the button it is not working

  29. 29

    application stops when I click on button

HotTag

Archive