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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:53:48+00:00 2026-06-04T15:53:48+00:00

I am using a text field to enter mobile nuber and I would like

  • 0

I am using a text field to enter mobile nuber and I would like to add done button to hide the keyboard, following is my code

    - (void)keyboardWillShow:(NSNotification *)note {  
        // create custom button
        UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
        doneButton.frame = CGRectMake(0, 163, 106, 53);
        doneButton.adjustsImageWhenHighlighted = NO;
        [doneButton setImage:[UIImage imageNamed:@"doneup.png"] forState:UIControlStateNormal];
        [doneButton setImage:[UIImage imageNamed:@"donedown.png"] forState:UIControlStateHighlighted];
        [doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];

        // locate keyboard view
       UIWindow* tempWindow = [[[UIApplication sharedApplication] windows]objectAtIndex:1];
    UIView* keyboard;
    for(int i=0; i<[tempWindow.subviews count]; i++) {
        keyboard = [tempWindow.subviews objectAtIndex:i];
        // keyboard found, add the button
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
            if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
                [keyboard addSubview:doneButton];
        } else {
            if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
                [keyboard addSubview:doneButton];
        }
   }
}

but I am unable to add the done button ,after cross check with break points , I observe that control is not entering into the if([[keyboard description] hasPrefix:@"UIKeyboard"] == YES) conditon.
I am using IOS5.

  • 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-04T15:53:49+00:00Added an answer on June 4, 2026 at 3:53 pm

    I did add a custom done-button in one of my projects too. The tutorial I used mentioned that piece of code:

    if([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2)
    {
        if([[tmpKeyboard description] hasPrefix:@"<UIPeripheralHost"] == TRUE)
            [tmpKeyboard addSubview:doneButton];
    }
    else
    {
        if([[tmpKeyboard description] hasPrefix:@"<UIKeyboard"] == TRUE)
            [tmpKeyboard addSubview:doneButton];
    }
    

    Prior to iOS version 3.2 your approach with UIKeyboard is fine, but later you have to change it to UIPeripheralHost.

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

Sidebar

Related Questions

I am using the following code to display phone number in text field in
I'm using the following code to show and hide a label on a text
I am using basic code to highlight the text within a text field when
I'm trying to add a text field to a form dynamically using javascript. From
Hi I am using the following code for a text box UITextField *txt_field =
I have a login page using jQuery Mobile which contains the following code: <div
A user may enter keywords into a text field and separate the keys using
I want to allow any user to create a category using a text field.
I'm have a TextViewCell with a text field that that I'm using in a
I have a text to validate using regex, Text field is allowed to have

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.