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 7702179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:10:09+00:00 2026-05-31T23:10:09+00:00

I created an instance of UIAlertView with two buttons and in the interface file

  • 0

I created an instance of UIAlertView with two buttons and in the interface file of my class(.h) I set the delegate too but still cant get any response when clicking the buttons. Here is my code:

 //myClass.h
    @interface MainMenu : UIViewController<UIAlertViewDelegate>
-(IBAction)secondAct:(id)sender;

And the implementation

-(IBAction)secondAct:(id)sender
      alert = [[UIAlertView alloc] initWithTitle:@"Dear User"
                                                        message:@"Your Request Will be Sent To Security"
                                                       delegate:nil
                                              cancelButtonTitle:@"Cancel"
                                              otherButtonTitles:@"OK", nil];
  [alert show];
  [alert autorelease];
}

and the delegate method:

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
 NSLog(@"UIAlertView delegate works");//this line too isnt displayed
 NSString *title=[ alertView buttonTitleAtIndex:buttonIndex ];
 if ([title isEqualToString:@"OK"]) {
NSLog(@"OK Pressed");
}//i want to create something like this

}
I did all of the code above but still can’t take any action. Whichever of the buttons i click, it dissmisses the alert. What is wrong with this code can any one help?
ANSWER

Dear PeterG. commented to change delegete:nil with delegate:self and it works now.

  • 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-31T23:10:10+00:00Added an answer on May 31, 2026 at 11:10 pm

    Delegate should probably be set to self. If it generates an error post it here.

    Also I do not think you should autorelease the alert ivar. Try to skip that line and see what happens?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm defining my own AR class in Rails that will include dynamically created instance
I am trying to access the singleton instance created by my WCF service but
I have created my custom MembershipProvider. I have used an instance of the class
I created instance of base class in derived class and tried to access protected
I want to create an instance of an IronPython class from C#, but my
The setup: PickerView (spinSelector) and label (chosenItem) added to ViewController. Created separate delegate class
How do I automate the process of getting an instance created and its function
Using the client-side ASP.NET AJAX library, I have created an instance of a client
I have created a multi-instance performance counter and I pass it mixed case instance
when installing SQLServer2005 developer edition (not express) I created a named instance: MYSERVERNAME/MYINSTANCENAME Is

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.