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

  • Home
  • SEARCH
  • 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 8869187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:25:33+00:00 2026-06-14T17:25:33+00:00

So I am trying simply to whenever the user presses the return on key

  • 0

So I am trying simply to whenever the user presses the return on key on a UITextField, the keyboard gets hidden, and THEN it calls a function. Right now I have:

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if(textField == _currentPasswordField)
    {
        [textField resignFirstResponder];
        [_passwordField becomeFirstResponder];
        return YES;
    }
    else if (textField == _passwordField)
    {
        [textField resignFirstResponder];
        [_confirmPasswordField becomeFirstResponder];
        return YES;
    }
    else
    {
        [textField resignFirstResponder];
        [self changePassword];
        return YES;
    }
}

But the keyboard gets hidden after the entire changePassword function has returned. How can I hide it and THEN call my function?!

Thanks!

  • 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-06-14T17:25:34+00:00Added an answer on June 14, 2026 at 5:25 pm

    The problem is that your changePassword method takes a long time to run, because it’s talking to a server over the network.

    All user interface updates, such as the keyboard hiding animation, are triggered from the main thread. When you call a slow method on the main thread, you prevent those user interface updates from happening.

    You need to move the call to changePassword off the main thread. There are many ways to do this. One of the simplest ways is to use Grand Central Dispatch (GCD), like this:

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [self changePassword];
    });
    

    However, this is not safe unless your changePassword method is thread-safe, so you need to think about what you’re doing in changePassword and what will happen it it’s running on a background thread while other methods are running on the main thread.

    You need to read the Concurrency Programming Guide, or watch some of the WWDC videos, like Session 211 – Simplifying iPhone App Development with Grand Central Dispatch from WWDC 2010.

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

Sidebar

Related Questions

I'm trying to write a very simple autosuggest type function so that, whenever a
I simply trying (in vain) to remove all instances of the word 'at' during
I'm simply trying to convert a CGEventTimestamp (which is an unsigned 64-bit integer roughly
I'm simply trying to crop a JPEG image (no scaling) using PHP. Here is
I am simply trying to draw a rectangle inside of a panel using flex4.
I am simply trying to display a users location on a map, I am
I am trying to simply add a Google Search bar onto my own map
I'm trying to simply remove all nested li elements within ul , but it
I'm trying to simply save a file. However, I need a filename entered without
I'm trying to simply test my RESTful API with cURL. Using the following invocation:

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.