[英]Using a segmented control to switch collection views
在iOS上,使用位于导航栏中的分段控件切换集合视图的正确/最有效方法是什么?
What you mean by switching? 切换是什么意思? Actually you can use a single collection view and change the data source of the collection according to the switch value
实际上,您可以使用单个集合视图并根据切换值更改集合的数据源
Add an action for your segmented control to change the data source 为您的分段控件添加操作以更改数据源
- (IBAction)changeCollectionViewData:(UISegmentedControl*)sender {
switch (sender.selectedSegmentIndex) {
case 0:
self.images =self.cars // displays images of cars;
break;
case 1:
self.images =self.bike // displays images of bikes;
break;
}
[self.collectionView reloadData]
}
// self.images is the data source array
Remember you need to set the numberOfItemsInSection accordingly 请记住,您需要相应地设置numberOfItemsInSection
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.