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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:31:57+00:00 2026-06-04T06:31:57+00:00

I have two table view filled in their viewDidLoad with data coming from a

  • 0

I have two table view filled in their viewDidLoad with data coming from a sqllite db containing names of shops. In the first view i choose one element (i.e. one shop), then in the second i have to choose another shop different from the first.

I can disable one of the row of the second table view after it has been filled?

I tried not to load the name (of the first shop choosen) in the second view but i fill the table view in its viewDidLoad and unfortunately the data regarding the name of the first shop choosen doesn’t seem to be available until the viewDidAppear and that moment is too late to fill the table view.

I tried, also, to add an alert to the event of choosing one row in the second view in this way

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   NSString *choosenSecondShop= [secondShop objectAtIndex:indexPath.row];
   NSString* nameFirstShop = [function loadFirstShopChoosen]; 

   if ([choosenSecondShop isEqualToString:nameFirstShop]) {
       NSString *message=@"Second shop cannot match the first";
       alert = [[UIAlertView alloc] initWithTitle:@"Errore"
            message: message
            delegate: self cancelButtonTitle: @"Ok" 
            otherButtonTitles:nil, 
            nil];
       [alert show];
    }else {
        // go on with the app's stuff!
    }
}

but in this case the alert is displayed but also the segue followed. I can prevent the segue to go on?

  • 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-04T06:31:58+00:00Added an answer on June 4, 2026 at 6:31 am

    There are a few different ways to attack this problem:

    1. Conditional segue

    This should work, though I’m not sure it’s a great idea from a user experience perspective.

    Presumably you made a segue in IB starting from the table cell? When you do that, you get the convenience of not needing any code to perform the segue (it’s automatically done when you tap the table cell), but you don’t get any run-time control over it either.

    If you need programmatic control over whether/when/which segue to perform, you should create a segue starting from the view controller itself (not from a control within it), and give the segue a unique identifier in IB. Then, in your tableView:didSelectRowAtIndexPath: implementation, you can call [self performSegueWithIdentifier:@"myIdentifier"] once you know you want to perform the segue.

    2. Disable cell selection

    To prevent a specific cell from being selected, your table view controller can implement tableView:willSelectRowAtIndexPath: to return nil for any index path you don’t want the user to select.

    If you do that, you might want to make it clear to the user which rows can be selected — you can alter the cell’s appearance in tableView:cellForRowAtIndexPath:.

    3. Don’t show the cell

    You say you’re populating the table view in viewDidLoad, but it doesn’t really work that way: Table views populate themselves by calling your data source & delegate methods when they need to. If you want to prevent an item from your data set from being shown as a cell in the table, you just need to alter the behavior of your data source & delegate methods:

    • tableView:numberOfRowsInSection: should return a number one less than it would otherwise
    • tableView:cellForRowAtIndexPath: should reflect the removal of the item; something like:

      MyShop *shop;
      if (indexPath.row < indexOfFirstShop)
          shop = [shops objectAtIndex:indexPath.row];
      else
          shop = [shops objectAtIndex:(indexPath.row + 1)];
      // then configure cell for the chosen shop
      

    Now, if you don’t know which row you want to hide as of the first time these methods are called, all you need to do once you get that information is tell the table view that it needs to call them again: [self.tableView reloadData] should do the trick.

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

Sidebar

Related Questions

I have two views.In first view, I have a table view and I am
I have two table in database A,B A: summary view of my data B:
I have a two sections in my table view. First contains two rows, and
I have two classes. In my first class i have table view which contains
I have a view table which is a union of two separate tables (say
I have two table first is TABLE_SUBJECT and second is TABLE_CHAPTER.Now i want to
I have two view controllers A and B. From A, I navigate to view
I have a table view and I'm toggling its dataDource with two UIButtons (like
I have two arrays, each containing strings. The first array is a list of
I have a table that has its content filled using one of the two

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.