分類菜單常見於電商 App,左側為一級分類,右側顯示對應商品或子分類。可透過 UITableView 與 UICollectionView 搭配資料過濾完成。
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"tagID = %ld", currentTagID];
self.rightDataList = [[self.allRightDataList filteredArrayUsingPredicate:predicate] mutableCopy];
[self.collectionView reloadData];
在 collectionView 停止滾動時,將 contentOffset.y 存入左側分類模型;再次切換到該分類時,可還原滾動位置。