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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:04:24+00:00 2026-05-30T05:04:24+00:00

I am trying to re-use cellViews using tags and Cell Identifiers, however the code

  • 0

I am trying to re-use cellViews using tags and Cell Identifiers, however the code below crashes whenever a cell is re-used. I think I’m almost there. Can anyone see the mistake?

// Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    const NSInteger BUTTON_TAG = 1001;
    const NSInteger SWITCH_TAG = 1002;
    const NSInteger TEXTFIELD_TAG = 1003;

    NSString *CellIdentifier = @"";
    if(indexPath.section == 2 && indexPath.row == 0)
        CellIdentifier = @"Button";
    else if (indexPath.section == 3)
        CellIdentifier = @"Switch";
    else
        CellIdentifier = @"TextField";


    UISwitch *switchView;
    UITextField *textField;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        if (CellIdentifier == @"TextField")
        {
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            CGRect frame = CGRectInset([cell.contentView bounds], 70, 10);
            textField = [[[UITextField alloc] initWithFrame:frame] autorelease];
            textField.keyboardType = UIKeyboardTypeDefault;
            textField.returnKeyType = UIReturnKeyDone;
            textField.autocorrectionType = UITextAutocorrectionTypeNo;
            textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
            textField.delegate = self;

            cell.accessoryView = textField;
            cell.tag = TEXTFIELD_TAG;

        }
        else if (CellIdentifier == @"Button")
        {
            cell.selectionStyle = UITableViewCellSelectionStyleBlue;
            cell.textLabel.textAlignment = UITextAlignmentCenter;
            cell.clipsToBounds=YES;
            cell.tag = BUTTON_TAG;
        }
        else if (CellIdentifier == @"Switch")
        {
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            switchView = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];

            cell.accessoryView = switchView;
            cell.tag = SWITCH_TAG;
        }
    }
    else
    {
        textField = (UITextField*)[cell viewWithTag:TEXTFIELD_TAG];
        switchView = (UISwitch*)[cell viewWithTag:SWITCH_TAG];     
    }

Crash Log

2012-02-22 14:50:08.352 ***[2304:207] -[UITableViewCell setSecureTextEntry:]: unrecognized selector sent to instance 0x6368270
2012-02-22 14:50:08.355 ***[2304:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCell setSecureTextEntry:]: unrecognized selector sent to instance 0x6368270'
  • 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-30T05:04:25+00:00Added an answer on May 30, 2026 at 5:04 am

    You don’t say what the crash is or provide a backtrace, but one problem I see right away is that you are always doing:

    switchView = (UISwitch*)[cell viewWithTag:SWITCH_TAG];     
    

    for all recycled cells even though only one of the three types has a switchView.

    You also only set TEXTFIELD_TAG for one kind of cell as well, yet refer to it when accessing all types of “recycled” cells.

    EDITED TO ADD: I see you’ve added the exception from your console. The exception is being thrown on a call to setSecureTextEntry. I don’t see setSecureTextEntry anywhere in the code you copy & pasted into the question, so I’d suggest looking for setSecureTextEntry in your real code and wherever it’s being called, make sure it’s a UITextField receiving that call and not a UITableViewCell (which can be the super view in which a secure UITextField lives).

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

Sidebar

Related Questions

I was trying use the code shown below to plot in such a way
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
trying to use the preferred on method call but the code is not working
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
Anyone know how to create a cvCreateStructuringElementEx using a image? I'm trying use opencv.cv.cvCreateStructuringElementEx()
I'm trying use make a div's background transparent using a mixture of CSS3 rgba()
I was trying use a set of filter functions to run the appropriate routine,
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying use a Java Uploader in a ROR app (for its ease

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.