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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:08:58+00:00 2026-05-12T06:08:58+00:00

I have an UITextField in a MyCustomUIView class and when the UITextField loses focus,

  • 0

I have an UITextField in a MyCustomUIView class and when the UITextField loses focus, I’d like to hide the field and show something else in place.

The delegate for the UITextField is set to MyCustomUIView via IB and I also have ‘Did End On Exit’ and ‘Editing Did End’ events pointing to an IBAction method within MyCustomUIView.

@interface MyCustomUIView : UIView { 

IBOutlet UITextField    *myTextField;

}

-(IBAction)textFieldLostFocus:(UITextField *)textField;

@end

However, neither of these events seem to get fired when the UITextField loses focus. How do you trap/look for this event?

The delegate for the UITextField is set as MyCustomUIView so I am receiving textFieldShouldReturn message to dismiss the keyboard when done.

But what I’m also interested in is figuring when the user presses some other area on the screen (say another control or just blank area) and the text field has lost focus.

  • 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-12T06:08:58+00:00Added an answer on May 12, 2026 at 6:08 am

    I believe you need to designate your view as a UITextField delegate like so:

    @interface MyCustomUIView : UIView <UITextFieldDelegate> { 
    

    As an added bonus, this is how you get the keyboard to go away when they press the “done” or return buttons, depending on how you have set that property:

    - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
      //This line dismisses the keyboard.       
      [theTextField resignFirstResponder];
      //Your view manipulation here if you moved the view up due to the keyboard etc.       
      return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITextField in my application. I'd like to restrict the set of
I have UITextField inside a UITableView. I've set the delegate of the text view
I have an UITextField and I would like that for every tap on a
I have a UITextField that I would like to enable auto completion on by:
I am new in ios development. I have a UITextField. There I set a
I have a UITextField which I am adding programmatically. I want to set the
I have a UITextField that I'd like to add a ? suffix to all
I have a UITextField in each cell of my tableview. I want to set
I have an UITextField and UIButton in a .xib. Button is under the field
I have a UITextField which I created programmatically. This text field is used to

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.