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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:18:34+00:00 2026-06-09T11:18:34+00:00

In my project I have several pages with many UITextField-s. So I figured it

  • 0

In my project I have several pages with many UITextField-s. So I figured it would be better to create an utility method named hideKeyboard which would work in any case.
Here is my solution, but actually something in this code doesn’t feel right.
Is there any better solutions for this?

+(void) hideKeyBoard {
    UITextField* t = [[UITextField alloc] initWithFrame:CGRectNull];
    [[UIApplication sharedApplication].keyWindow addSubview:t];
    [t becomeFirstResponder];
    [t resignFirstResponder];
    [t removeFromSuperview];
}
  • 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-09T11:18:35+00:00Added an answer on June 9, 2026 at 11:18 am

    A pretty simple solution is to use the responder chain as noted here

    [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) 
                                               to:nil 
                                             from:nil
                                         forEvent:nil];
    

    By sending the action to nil it get sent into the responder chain and of course the first object that get’s a chance to respond is the object that is the firstResponder

    Side note
    The only reason I saw this post is because of the weekly newsletter iOSDevWeekly, which is definitely worth subscribing to

    Edit

    I guess brute force way of doing it would be

    [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a jsf project, and I have several xhtml pages which use
We have several html pages which we are storing as resources within our project.
I have several xaml pages in a WP7 MVVM project. I want to take
I have several wiki pages on my project hosted on Google Code. How do
I have several web sequential pages which will modify a record and its child
I have a problem, that I have several pages in my project and I
I have a project that sets up several pages with articles. Each page has,
I have several Razor pages in an MVC4 project that follow a general layout
I have several modules of a project and i have made each module as
I'm working on a project where we have several SOAP Web Services developed on

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.