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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:56:56+00:00 2026-05-29T07:56:56+00:00

I have a UIAlertView with a textField on it and two buttons: Save &

  • 0

I have a UIAlertView with a textField on it and two buttons: Save & Cancel. When the Save button is tapped I am checking if the text field isn’t empty and after if it is I simply want to change the textFields placeholder to: @”enter a name please” and KEEP the alert view on screen. However it is automatically dismissed.

How do I override that?

  • 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-29T07:56:58+00:00Added an answer on May 29, 2026 at 7:56 am

    Add a target to the textfield in a subclassed alertView. You can subclass the alertView and not dismiss as described in this post

    [[alertView textFieldAtIndex:0] addTarget:self action:@selector(textFieldDidChange) forControlEvents:UIControlEventEditingChanged];
    

    Then write a function called textFieldDidChange that checks the current textfield of your alertView and set a boolean value so you know whether or not to dismiss the alert.

    - (void) textFieldDidChange
    {
      NSString *alertViewText = [[alertView textFieldAtIndex:0] text];
    
      if ([alertViewText isEqualToString:@""]) {
        [alertView setMessage:@"Enter a name please."];
      } else {
        [alertView setMessage:@"Default Message"];
      }
    }
    

    * Alternatively, I would suggest disabling “Save” when it is empty and not have to subclass. *

    - (void) textFieldDidChange
    {
      NSString *alertViewText = [[alertView textFieldAtIndex:0] text];
    
      if ([alertViewText isEqualToString:@""]) {
        [alertView setMessage:@"Enter a name please."];
        for (UIViewController *view in alertView.subview) {
           if ([view isKindOfClass:[UIButton class]]) {
              UIButton *button = (UIButton *)view;
              if ([[[button titleLabel] text] isEqualToString:@"Save"])
                 [button setEnabled:NO];
           }      
        }
      } else {
        [alertView setMessage:@"Default Message"];
        for (UIViewController *view in alertView.subview) {
           if ([view isKindOfClass:[UIButton class]]) {
              UIButton *button = (UIButton *)view;
              if ([[[button titleLabel] text] isEqualToString:@"Save"])
                 [button setEnabled:YES];
           }      
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an alert view with two buttons using the following code: UIAlertView
I have a UIAlertView with a text field in it. This view works correctly;
I have a UIAlertView with several buttons. I want to make a certain button
Is there a way to have the button of a UIAlertView go to the
I have a textfield that the user inputs, then I save it with NSKeyedArchiver
i have been trying to copy text input from alertview textfield to a NSMutableArray
I have a UIAlertView with an image and a large button. The problem is
I have a textField and a button. On the button I defined an alertview
I have two UIAlertView s in same view controller and I want to use
I'm trying to save a String from a textfield. I have a IBOutlet UITextField

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.