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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:55:41+00:00 2026-05-27T04:55:41+00:00

How would you go about mimicing the iPhones keypad input. So that when you

  • 0

How would you go about mimicing the iPhones keypad input. So that when you click one 1 is displayed then 2 then it is 12… so on and so forth along with the ( ) -. I don’t want to use the actual phone app because I’m creating a false dialer, but I want it to look and function kind of like the actual thing.

Any ideas would be greatly appreciated thanks.

EDIT:

Ok so I put in all the buttons needed but I ended up making them all individual buttons. THey are all linked including the label and this is what one button and the updater looks like.

-(IBAction)zeroButton:(id)sender{
self.enteredPhoneNumberString = [self.enteredPhoneNumberString stringByAppendingString:[NSString stringWithFormat:@"%d", "0"]];
[self updateFormattedPhoneNumberLabel];

}

-(void)updateFormattedPhoneNumberLabel {
    if ([self.self.enteredPhoneNumberString length] > 3) {
        NSString *firstThree = [self.enteredPhoneNumberString substringToIndex:2];
        NSString *lastSet = [self.enteredPhoneNumberString substringFromIndex:2];
        self.label.text = [NSString stringWithFormat:@"%@-%@", firstThree, lastSet];
    }
    else if ([self.self.enteredPhoneNumberString length] > 7) {
        NSString *firstThree = [self.enteredPhoneNumberString substringToIndex:2];
        NSString *secondThree = [self.enteredPhoneNumberString substringToIndex:2];
        NSString *lastSet = [self.enteredPhoneNumberString substringFromIndex:2];
        self.label.text = [NSString stringWithFormat:@"(%@) %@-%@", firstThree, secondThree, lastSet];
    }
}

I had also tried it with the “” not being around the numbers being appended. Any idea why nothing is being displayed?

NEW EDIT:

I added enteredPhoneNumberString = @””; and with the numbers formatted the way you original had it displays the numbers. The main issue I’m having now is getting it so that the () and – pop up in the right spots.

  • 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-27T04:55:42+00:00Added an answer on May 27, 2026 at 4:55 am

    I would suggest creating a grid of UIButtons that mimics the numpad, these buttons all call a method such as keyPadButtonTouchedUpInside:(id)sender and have a tag that corresponds to the number it represents.

    Implementation of keyPadButtonTouchedUpInside:(id)sender may look like…

    - (void)keyPadButtonTouchedUpInside:(id)sender {
        UIButton *touchedButton = (UIButton *)sender;
        if (touchedButton.tag <= 9) {
             self.enteredPhoneNumberString = [self.enteredPhoneNumberString stringByAppendingString:[NSString stringWithFormat:@"%d", touchedButton.tag]];
             [self updateFormattedPhoneNumberLabel];
        } else {
             // maybe some other code for pounds/stars entered on the keypad if you have these
             // you will also be checking if the user hit the backspace key and trim your
             // phone number string by 1
        }
    }
    

    Now you need to implement updateFormattedPhoneNumberLabel

    This will look at the instance NSString variable self.enteredPhoneNumberString and update a UILabel that you have in place to display the number.

    updateFormattedPhoneNumberLabel might look like…

    - (void)updateFormattedPhoneNumberLabel {
        if ([self.self.enteredPhoneNumberString length] > 3) {
             NSString *firstThree = [self.enteredPhoneNumberString subStringToIndex:2];
             NSString *lastSet = [self.enteredPhoneNumberString subStringFromIndex:2];
             self.formattedPhoneNumberLabel.text = [NSString stringWithFormat:@"%@-%@", firstThree, lastSet];
        } else if .... 
          // more conditions to check for other lengths of the 
          // entered number and continue with the proposed formatting methods. 
    

    Hopefully that gets you down the path, there may be more efficient methods for doing this but in reality its not an intensive operation so I wouldn’t worry to much about optimization unless you see some kind of entry lag which I wouldn’t expect.

    EDIT

    I would probably update the formatting conditions so that the formatting happens in the following behavior.

    1-3 numbers entered shows as “1”, “12”, or “123”

    4-7 numbers entered shows as “123-4”, “123-45”, “123-456”, or “123-4567”

    8-10 numbers entered show as “(123) 456-78”, “(123) 456-789”, or “(123) 456-7890”

    11 numbers entered show as “1+(234)-567-8901”

    Anything more than 11 I would just show a string of numbers, unless you want to get into formatting non-us numbers. You should also play around with entering numbers in the Phone App to see how it responds if you want to mimic it completely.

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

Sidebar

Related Questions

Just wondering how people would go about this. Say I have one class that
I have a GridView that (in one particular instance) would contain about 5000 rows,
Just a quick question about how you would go about implementing this. I want
I would like to know how I would go about altering the HTML that
As a programmer I have no idea how one would go about programming menus
Does anybody know how one would go about looping through all the elements in
I'm trying to find documentation on how one would go about creating a custom
I'm wondering how one would go about redirecting the stdin of a script from
How would go about writing proper unit testing (and integration testing for that matter)
I needed to know how one would go about setting up a default avatar

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.