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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:49:56+00:00 2026-06-08T13:49:56+00:00

I feel bad asking this question. I have seen it on SO a couple

  • 0

I feel bad asking this question. I have seen it on SO a couple of times, but I am not understanding the answers. I have a custom keyboard that I made in a separate view. It worked great for one text box. But now I want to have multiple text boxes that the keyboard will enter numbers in. I have made the view controller the textfield delegate and my custom keyboard pops up when you enter either of the text boxes. However, the code that I have to set the numbers is only for one of the text boxes. So I wanted to check to see which text box was selected so I will be editing in that box. I used the method – (BOOL)textFieldShouldBeginEditing:(UITextField *)textField and tried the following code…

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if ([numberOne isFirstResponder]) 
{
    [self.numberOne = currentTextField];    
}
else if ([numberTwo isFirstResponder])
{
    [self.numberTwo = currentTextField];
}    
}

the currentTextField is a UItextField. I then wanted to substitute currentTextField in the following code to replace numberOne.

- (IBAction)buttonPressed:(UIButton *)sender 
{
NSString *button = [sender currentTitle];
NSRange decimalpoint = [self.numberOne.text rangeOfString:@"."];
if (self.userIsEnteringANumber)
{
    if ([button isEqualToString:@"."] && decimalpoint.location != NSNotFound)
    {
        self.numberOne.text = self.numberOne.text;
    }else 
        self.numberOne.text = [self.numberOne.text stringByAppendingString:button];
}else 
{
    self.numberOne.text = button;
    self.userIsEnteringANumber = YES;
}
}

However, the complier doesn’t like my line [self.numberOne = currentTextField]; I tried following some of the other advice, but unfortunately I don’t understand what they are saying. Does anyone have newbie directions for me? Thanks so much in advance.

I have fixed the compiler issue with the help from spacious. Thanks. My textFieldShouldBeginEditing method is now…

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if ([numberOne isFirstResponder]) 
{
    self.currentTextField = self.numberOne;    
}
else if ([numberTwo isFirstResponder])
{
    self.currentTextField = self.numberTwo;
}
return YES;
} 

and I changed the IBAction buttonPressed to the following…

- (IBAction)buttonPressed:(UIButton *)sender 
{
NSString *button = [sender currentTitle];
NSRange decimalpoint = [self.currentTextField.text rangeOfString:@"."];
if (self.userIsEnteringANumber)
{
    if ([button isEqualToString:@"."] && decimalpoint.location != NSNotFound)
    {
        self.currentTextField.text = self.currentTextField.text;
    }else 
        self.currentTextField.text = [self.currentTextField.text stringByAppendingString:button];
}else 
{
    self.currentTextField.text = button;
    self.userIsEnteringANumber = YES;
}
}

And now something weird happens. When I click on the first text field, the keyboard comes up but nothing happens, then I hit the second text field and editing begins in the first text field. If I click on the first text field, editing begins on the second. Any help would be appreciated!!

  • 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-08T13:49:58+00:00Added an answer on June 8, 2026 at 1:49 pm

    Well, I can answer your compiler question-

    To assign a reference to currentTextField, it should be:

    currentTextField = self.numberOne;

    Brackets are used when sending messages (calling methods on objects).

    You wrapped your assignment in brackets and the assignment is the wrong way.

    (You’d currently be overwriting your references to your textFields with currentTextField)

    I would need to see more code to diagnose any further! Good luck

    EDIT: (these are untested changes, but you’ll get the idea)

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    {
    if ([numberOne isFirstResponder] ) 
    {
        self.currentTextField = self.numberOne;
        self.userIsEnteringANumber = NO;
    }
    else if ([numberTwo isFirstResponder])
    {
        self.currentTextField = self.numberTwo;
        self.userIsEnteringANumber = NO;
    
    }    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel bad asking this question but I am currently not able to program
I feel really dumb for asking this question, but here it goes. I have
I feel bad about not getting this. But, although I have read several articles
I feel bad about asking a question so simple, but I can't figure this
I feel bad for asking this, but I can't find any answer on the
I feel silly for asking, but how do I get plan value in this
I feel like such a noob asking this but, for some reason a horizontal
I feel like I've only ever seen this here on SO, but I can't
Hmmm this seems silly, so I feel silly. I have a custom operation on
I feel pretty ignorant asking this, but would someone be able to explain 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.