开发者

Change the table View when segmented Control is tapped. Exactly as in APPSTORE app. How to do it?

开发者 https://www.devze.com 2022-12-16 11:33 出处:网络
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 CommonT

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 segme开发者_如何学Pythonnt is tapped the a new tableView from same CommonTableViewController should be loaded. How can it be done? thanks in advance.


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];


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号