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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:55:35+00:00 2026-05-24T01:55:35+00:00

I sort the UITableView as in this answer How to sort alphabetically a UITableView

  • 0

I sort the UITableView as in this answer How to sort alphabetically a UITableView Sectioned?.

The problem is now that UITableView doesn’t push out the correct ViewControllers, due i have 2 localizations, English and Italian in my app. For english it works fine, but for italian not.

The code I’m using is this,as suggested in this answer Pushing View Controllers in UITableViewController Grouped:

if (indexPath.section == 0) 
{   
     switch (indexPath.row) {
        case 0:
        [self.navigationController pushViewController:[[[FirstViewController alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
        break;

        case 1:
        [self.navigationController pushViewController:[[[SecondViewController alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
        break;
        // and so on
    }
} 

Any ideas for this?

  • 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-24T01:55:36+00:00Added an answer on May 24, 2026 at 1:55 am

    Your problem is totally logical and does not need a change in your code. When you sort the tableView array, it is trivial that didSelectRowAtIndexPath would get messed up while selecting rows.

    This might be because you would have implemented something like

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
    if (indexPath.section == 0)
       {
        if (indexPath.row ==0)
             // PushViewController to view 1 //
    
        if (indexPath.row ==1)
             // PushViewController to view 2 //
    
       }
    
    if (indexPath.section ==1)
       // Do something like before
    

    If this is your case, then yes, when your sort the tableView you will push view controllers in a BAD WAY.

    My suggestion is that you can take some properties in each row and check for that while pushing view controllers. For example, if you are… (say) having row 1 to be a certain letter or a number or a word, you can check for that and pushViewController accordingly.

    But this will work only if you know all the elements in the tableView (never mind sorting).

    You can check something like…

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
     UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
    
     if (selectedCell.textLabel.text = @"1")
       // push view controller to view 1
    
     if (selectedCell.textLabel.text isEqualToString: self.lifeStyle) 
        // push view controller to lifeStyleViewController
    
        // here lifeStyle is a NSString property // 
    

    You can check for anything if you logically set and assign your properties in the cellForRowAtIndexPath method and logically set it such that when you perform a tableView reloadData after sorting, the flow of the didSelect would still be the same.

    Let us know if you still have problems.

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

Sidebar

Related Questions

I've had this sort of problem before, and it didn't get a satisfactory answer.
I have a UITableView containing names that I would like to group (and sort)
I have a sectioned UITableView with 3 categories. I'm using this code: NSArray *arrayOne
I have a problem that I had working in a test but now in
Sort of a methods/best practices question here that I am sure has been addressed,
I sort of understand this, at least the function of generators (I've used them
I have a very strange problem with a UITableview within a navigation controller on
I am currently parsing some xml that looks like this <Rows> <Row MANUFACTURERID=76 MANUFACTURERNAME=Fondont
I need some help. I have a UITableView that has cells that hold the
I've been googling around to try to figure out what sort of event handles

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.