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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:03:58+00:00 2026-05-25T00:03:58+00:00

following code sets cell texts and add a checkMark only to last selected. Always

  • 0

following code sets cell texts and add a checkMark only to last selected. Always only one cell check marked and works properly excepting when it is displayed for first time. So, text is not showed for that cell (only that one) until you press any other cell. For example, if cellPos = 4 when viewDidLoad, that cell will not contain text.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSString* cellIdentifier = @"cellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if(cell == nil)
    {
        cell = (UITableViewCell*) [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];

    }
    cell.accessoryType = UITableViewCellAccessoryNone;


    if (indexPath.section == 0) {


        if(indexPath.row == cellPos)
        {
            cell.accessoryType = UITableViewCellAccessoryCheckmark; 
            cell.selected = YES;
        }
        else
        {
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.selected = NO;
        }



        switch (indexPath.row) {
            case 0:
                cell.textLabel.text = @"English";
                cell.imageView.image = [UIImage imageNamed:@"english.png"];
                break;
            case 1:
                cell.textLabel.text = @"Español";
                cell.imageView.image = [UIImage imageNamed:@"spanish.png"];
                break;
            case 2:
                cell.textLabel.text = @"Deutsch";
                cell.imageView.image = [UIImage imageNamed:@"germany.png"];
                break;
            case 3:
                cell.textLabel.text = @"Français";
                cell.imageView.image = [UIImage imageNamed:@"french.png"];
                break;
            case 4:
                cell.textLabel.text = @"Italiano";
                cell.imageView.image = [UIImage imageNamed:@"italian.png"];
                break;
            default:
            break;}
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    cellPos = indexPath.row;
    [tableView reloadData];
}
  • 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-25T00:03:58+00:00Added an answer on May 25, 2026 at 12:03 am

    Have you tried moving the if-else block after the switch block? This way you set the text of the cell before you set the cell to selected. The fact that it only occurs the first time suggests to me that it may be an order of operations problem.

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

Sidebar

Related Questions

This post concerns only IE. The last line of the following code is causing
Why doesn't the following code set the XML declaration encoding type? It always sets
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie
following code doesn't work with input: 2 7 add Elly 0888424242 add Elly 0883666666
The following code works great in IE, but not in FF or Safari. I
Why does the following simplified code not sets the font-size of the TextBlock to
I'm using the following code to create three sets of plots in the amazing
I have the following code in my codebehind Page_Load function that sets the default
The following code works on insert but on update modifier is never set, any
I am using the jquery datatable plugin. I have the following code that sets

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.