Question

I am having a SampleViewController in which a segmentedControl is added at the top below nav bar(not inside it).Now below the segmentedControl i want a tableView which loads from another class CommonTableViewController. When a segment is tapped the a new tableView from same CommonTableViewController should be loaded. How can it be done? thanks in advance.

Was it helpful?

Solution

I use an array to populate my tableView...

In my segmentedControlClicked method... I change the data in the array based on which segment was selected and then use this line of code:

[self.tableView reloadData];

OTHER TIPS

If you already have 2 UITableViews then just remove the first from the screen and add the other. LIke

[tableView1 removeFromSuperview];
[self.view indertSubview:tableView2 atIndex:self.view.subviews.count];

Depending on the case, you might also want to consider haveing one tableView and just changing the data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top