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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:13:38+00:00 2026-05-28T07:13:38+00:00

My UITableViewCell has UITextField inside, now I want to get UITextField data to be

  • 0

My UITableViewCell has UITextField inside, now I want to get UITextField data to be stored in database (using insert command) but how can I be able to access the UITableViewCell‘s UITextField data

@interface ELCTextfieldCell : UITableViewCell <UITextFieldDelegate> {

    id delegate;
    UILabel *leftLabel;
    UITextField *rightTextField;
    NSIndexPath *indexPath;
}

@implementation ELCTextfieldCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {

        leftLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [leftLabel setBackgroundColor:[UIColor clearColor]];
        [leftLabel setTextColor:[UIColor colorWithRed:.285 green:.376 blue:.541 alpha:1]];
        [leftLabel setFont:[UIFont fontWithName:@"Helvetica" size:12]];
        [leftLabel setTextAlignment:UITextAlignmentRight];
        [leftLabel setText:@"Left Field"];
        [self addSubview:leftLabel];

        rightTextField = [[UITextField alloc] initWithFrame:CGRectZero];
        rightTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        [rightTextField setDelegate:self];
        [rightTextField setPlaceholder:@"Right Field"];
        [rightTextField setFont:[UIFont systemFontOfSize:17]];

        // FOR MWF USE DONE
        [rightTextField setReturnKeyType:UIReturnKeyDone];

        [self addSubview:rightTextField];
    }

    return self;
}

//Layout our fields in case of a layoutchange (fix for iPad doing strange things with margins if width is > 400)
- (void)layoutSubviews {
    [super layoutSubviews];
    CGRect origFrame = self.contentView.frame;
    if (leftLabel.text != nil) {
        leftLabel.frame = CGRectMake(origFrame.origin.x, origFrame.origin.y, 90, origFrame.size.height-1);
        rightTextField.frame = CGRectMake(origFrame.origin.x+105, origFrame.origin.y, origFrame.size.width-120, origFrame.size.height-1);
    } else {
        leftLabel.hidden = YES;
        NSInteger imageWidth = 0;
        if (self.imageView.image != nil) {
            imageWidth = self.imageView.image.size.width + 5;
        }
        rightTextField.frame = CGRectMake(origFrame.origin.x+imageWidth+10, origFrame.origin.y, origFrame.size.width-imageWidth-20, origFrame.size.height-1);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {

    if([delegate respondsToSelector:@selector(textFieldDidReturnWithIndexPath:)]) {

        [delegate performSelector:@selector(textFieldDidReturnWithIndexPath:) withObject:indexPath];
    }

    return YES;
}

- (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {

    NSString *textString = self.rightTextField.text;

    if (range.length > 0) {

        textString = [textString stringByReplacingCharactersInRange:range withString:@""];
    } 

    else {

        if(range.location == [textString length]) {

            textString = [textString stringByAppendingString:string];
        }

        else {

            textString = [textString stringByReplacingCharactersInRange:range withString:string];   
        }
    }

    if([delegate respondsToSelector:@selector(updateTextLabelAtIndexPath:string:)]) {       
        [delegate performSelector:@selector(updateTextLabelAtIndexPath:string:) withObject:indexPath withObject:textString];
    }

    return YES;
}

@interface RootViewController : UITableViewController <ELCTextFieldDelegate> {

    NSArray *labels;
    NSArray *placeholders;
}

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.labels = [NSArray arrayWithObjects:@"First Name", 
                                            @"Last Name", 
                                            @"Email", 
                                            @"Phone Number", 
                                            nil];

    self.placeholders = [NSArray arrayWithObjects:@"Enter First Name", 
                                                  @"Enter Last Name", 
                                                  @"Enter Email", 
                                                  @"Phone Number (Optional)", 
                                                  nil];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    ELCTextfieldCell *cell = (ELCTextfieldCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[ELCTextfieldCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    [self configureCell:cell atIndexPath:indexPath];

    return cell;
}
  • 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-28T07:13:39+00:00Added an answer on May 28, 2026 at 7:13 am

    Try setting tag value to the textField and then retrieve the values.

    Ex: rightTextField.tag = 1000; // don’t use 0

    Access the textField using,

    UITextField *textField = (UITextField *)[self.view viewWithTag:1000];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use a UITextField inside a UITableViewCell as you can see in
How to tell when a UISwitch inside of a UITableViewCell has been tapped? My
I have a UITextField inside a UITableViewCell. It will not activate on the iPad
I have a UITableViewCell that has some labels and images that can be clicked.
I want to draw the background of a UITableViewCell which has a grouped style.
I am using a custom UITableViewCell, which has some labels. There is one label
I have a custom UITableView using UITableViewCell s. Each UITableViewCell has 2 buttons. Clicking
My app has a UITextField inside of a table cell. The table cell is
I have a custom uitableviewcell. It has a uitextfield. I'd like the parent tableview
i want to highlight or animate the uitableviewcell when local notification has been fired

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.