Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6205251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:14:21+00:00 2026-05-24T05:14:21+00:00

Currently I am using the following code to present a UIAlertView: UIAlertView *alert =

  • 0

Currently I am using the following code to present a UIAlertView:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Today's Entry Complete"
                        message:@"Press OK to submit your data!" 
                       delegate:nil 
              cancelButtonTitle:@"OK" 
              otherButtonTitles: nil];
    [alert show];
    [alert release];

How do I get it so that when ‘OK” is pressed, it triggers a function, say -(void)submitData

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:14:22+00:00Added an answer on May 24, 2026 at 5:14 am

    NOTE:

    Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) To create and manage alerts in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert.

    Please check this out tutorial

    “deprecated” means???

    Objectvie C

    .h file

        @interface urViewController : UIViewController <UIAlertViewDelegate> {
    

    .m file

    // Create Alert and set the delegate to listen events
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Today's Entry Complete"
                                                    message:@"Press OK to submit your data!"
                                                   delegate:self
                                          cancelButtonTitle:nil
                                          otherButtonTitles:@"OK", nil];
    
    // Set the tag to alert unique among the other alerts.
    // So that you can find out later, which alert we are handling
    alert.tag = 100;
    
    [alert show];
    
    
    //[alert release];
    
    
    -(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    
        // Is this my Alert View?
        if (alertView.tag == 100) {
            //Yes
    
    
        // You need to compare 'buttonIndex' & 0 to other value(1,2,3) if u have more buttons.
        // Then u can check which button was pressed.
            if (buttonIndex == 0) {// 1st Other Button
    
                [self submitData];
    
            }
            else if (buttonIndex == 1) {// 2nd Other Button
    
    
            }
    
        }
        else {
         //No
            // Other Alert View
    
        }
    
    }
    

    Swift

    The Swifty way is to use the new UIAlertController and closures:

        // Create the alert controller
        let alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert)
    
        // Create the actions
        let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default) {
            UIAlertAction in
            NSLog("OK Pressed")
        }
        let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
            UIAlertAction in
            NSLog("Cancel Pressed")
        }
    
        // Add the actions
        alertController.addAction(okAction)
        alertController.addAction(cancelAction)
    
        // Present the controller
        self.presentViewController(alertController, animated: true, completion: nil)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using the following code to create a web request: Dim myRequest
I'm currently using the following code to append a X link to each element
I'm currently using the following code (C#): private static void PlayLoop(string filename) { Audio
I'm currently using StructureMap to inject instances of NHibernate ISessions using the following code:
I'm currently using the following PHP code: // Get all subordinates $subords = array();
I am using currently the following code to populate a combobox: combobox.DataSource = datatable;
In short, currently I am using the following code to pull records from multiple
I'm currently downloading an HTML page, using the following code: Try Dim req As
I am currently using PHP_Beautifier for formatting code with the following command like options
Im using the following code to present a file for download. The file saves

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.