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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:51:20+00:00 2026-06-18T04:51:20+00:00

i am wondering how i would handle closing keyboard in UITextField, i know how

  • 0

i am wondering how i would handle closing keyboard in UITextField, i know how to do it when i do it via Outlets, but now i am declaring my textfields in code like this:

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}

cell.accessoryType = UITableViewCellAccessoryNone;

UITextField *playerTextField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 185, 30)];
playerTextField.adjustsFontSizeToFitWidth = YES;
playerTextField.textColor = [UIColor blackColor];
if([indexPath row] == 0) {
    playerTextField.placeholder = @"Server Address";
    playerTextField.keyboardType = UIKeyboardTypeDefault;
    playerTextField.returnKeyType = UIReturnKeyDone;
} else if([indexPath row] == 1){
    playerTextField.placeholder = @"Server Port";
    playerTextField.keyboardType = UIKeyboardTypeDecimalPad;
    playerTextField.returnKeyType = UIReturnKeyDone;
} else {
    playerTextField.placeholder = @"Password";
    playerTextField.keyboardType = UIKeyboardTypeDefault;
    playerTextField.returnKeyType = UIReturnKeyDone;
    playerTextField.secureTextEntry = YES;
}

playerTextField.backgroundColor = [UIColor clearColor];
playerTextField.autocorrectionType = UITextAutocorrectionTypeNo;
playerTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
playerTextField.textAlignment = UITextAlignmentLeft;
playerTextField.tag = 0;

playerTextField.clearButtonMode = UITextFieldViewModeNever;
[playerTextField setEnabled: YES];

[cell.contentView addSubview:playerTextField];


return cell;
}

How would i manage that?

  • 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-18T04:51:21+00:00Added an answer on June 18, 2026 at 4:51 am

    Because your textfield is inside a cell, you need to tag it, which you already are, however i would recommend using something different than 0. then whenever you need to resign it (assuming you know which cell to look for) :

        UITextField *myField = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:myRow inSection:mySection]].contentView viewWithTag:myTag];
        [myField resignFirstResponder];
    

    if you dont know which cell it is then youll need to loop through all the cells.

    hope this helps

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

Sidebar

Related Questions

I'm wondering what would be best to do. Right now I have running a
i was wondering what would be the best way to code a browser plugin
I'm wondering what would be considered best practise for this. It's fairly inconsequential but
I've written my own model to handle authentication but I was just wondering how
I was wondering what would be the best way to handle errors in an
Im doing a reservation application and was wondering how would i handle the following
Was wondering what the best way to handle this would be. Say I have
I was wondering how NSCoder would handle an object that was shared and encoded
I was wondering what would be the best way to handle an application timeout,
I was wondering how I would handle aggregate roots that contain collections with a

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.