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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:50:32+00:00 2026-06-09T18:50:32+00:00

I want to have a CellTextField within a UITableViewCell only accept numeric chars. I

  • 0

I want to have a CellTextField within a UITableViewCell only accept numeric chars.
I programmatically create UITableViewCells like this:

    -(UITableViewCell*) getCellContentView: (NSString*) cellIdentifier {

        ...

        UITableViewCell *cell = [[UITableViewCell alloc] initWithFrame:cellFrame reuseIdentifier:cellIdentifier];

        ... 

        CellTextField *txt;  
        txt = [[CellTextField alloc] initWithFrame:amountFrame];

        ... //here we should setup a delegate or similar to handle char validation for txt

        [cell.contentView addSubview:txt];
        return cell;
    }

For the UITextField component we have a Delegate ‘shouldChangeCharactersInRange’ but I can’t find the equivalent for CellTextFields.

  • 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-09T18:50:34+00:00Added an answer on June 9, 2026 at 6:50 pm

    try this one

    .h

      @interface YourClass : ParentClass <UITextFieldDelegate>{
      NSNumberFormatter *integerNumberFormatter;
      }
      @end
    

    .m

    -(void)viewDidLoad
    {
          [integerNumberFormatter setMaximumFractionDigits:0];
           yourTextField.delegate = self;
    }
    
    - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    
        NSString* proposedString = [textField.text stringByReplacingCharactersInRange:range withString:string];
        NSNumber *proposedNumber = [integerNumberFormatter numberFromString:proposedString];
        if (proposedNumber) {
            NSString *integerString = [integerNumberFormatter stringFromNumber:proposedNumber];
            if ([integerString isEqualToString:proposedString]) {
                // proposed string is an integer
                return YES;
            }
        }
    
        return NO;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simllar question like here: static-method-invocation , but in PHP. Simply, I want
I want have this ability to select multiple items with checkboxes and delete them
I want have a view like iPhone's calendars app. Anybody help to show me
I have a string: string = %q{<span class=no>2503</span>read_attribute_before_type_cast(<span class=pc>self</span>.class.primary_key)} In this example I want
Ok, so I have this html-page (full of different urls), where I want to
I am trying to create a jquery plugin, and I want have the following
want to have search functionality as on this website http://www.carwale.com/new/search.aspx#budget=6&budget=8&fuel=2 here whenever the user
i want have an image and i want to set it as a background
I have a UITextView and I want have two buttons. When the user taps
I try to read out all existing calendars. I want have a HashMap with

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.