In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to realize the commodity classification page in collectionview". In the operation of the actual case, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The first level of classification on the left is displayed by tableview, and the classification of headphones on the right is displayed by collectionview, which is mainly to achieve the linkage of the first and second levels of classification. The following is mainly about clicking and swiping.
1. Click to realize the first level classification on the left.
-(void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {[tableView deselectRowAtIndexPath:indexPath animated:YES]; if (indexPath.row! = selectTableIndex) {/ / determine whether the slide is caused by clicking on the first level category isClickLeft = YES; selectTableIndex = indexPath.row; [tableView reloadData] / / the secondary classification slides to the corresponding area [_ classCollectionView scrollToItemAtIndexPath: [NSIndexPath indexPathForRow:0 inSection:selectTableIndex] atScrollPosition:UICollectionViewScrollPositionTop animated:YES]; / / Let the sliding of collectionview fall back the height of sectionheader _ classCollectionView.contentOffset = CGPointMake (0, _ classCollectionView.contentOffset.y-70) Dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t) (0.2 * NSEC_PER_SEC)), dispatch_get_main_queue (), ^ {isClickLeft = NO;});}}
2. Change the selection of the first-level classification in the agent method of collectionview
/ / collectionview the method called by the header and tail view to be loaded-(void) collectionView: (UICollectionView *) collectionView willDisplaySupplementaryView: (UICollectionReusableView *) view forElementKind: (NSString *) elementKind atIndexPath: (NSIndexPath *) indexPath {if (isClickLeft) {return;} CGPoint point = [view convertPoint:CGPointZero toView:self.view] / determine whether it is SectionHeader if (point.y < 100 & & [elementKind isEqualToString:UICollectionElementKindSectionHeader]) {/ update the indexpath selectTableIndex = indexPath.section; [_ classTableView reloadData] of the currently selected first-level category }} / collectionview has loaded the method called by the header and tail view-(void) collectionView: (UICollectionView *) collectionView didEndDisplayingSupplementaryView: (UICollectionReusableView *) view forElementOfKind: (NSString *) elementKind atIndexPath: (NSIndexPath *) indexPath {if (isClickLeft) {return;} CGPoint point = [view convertPoint:CGPointZero toView:self.view] / determine whether it is SectionHeader if (point.y < 100 & & [elementKind isEqualToString:UICollectionElementKindSectionHeader]) {/ update the indexpath selectTableIndex = indexPath.section; [_ classTableView reloadData] of the currently selected first-level category;} this is the end of the content of "how collectionview implements the commodity classification page". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 243
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.