实现tableView和collectionView的相互关联方法
来源:互联网 发布:阿里云ssh登录 编辑:程序博客网 时间:2024/06/01 18:44
最近比较忙,没事帮别人做个小Demo,其实很简单.不用多少时间,看看核心实现吧.
用到的方法
#pragma mark 返回头视图 / 尾视图 通过kind判断
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
//这个就不多说了
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView ==self.collectionView) {
if (isGetWhatWay ==YES) {
// 将collectionView在控制器view的中心点转化成collectionView上的坐标
CGPoint pInView = [selfconvertPoint:self.collectionView.centertoView:self.collectionView];
// 获取这一点的indexPath
NSIndexPath *indexPathNow = [self.collectionViewindexPathForItemAtPoint:pInView];
if (indexPathNow.section ==0) {
//获取所有collectionView的头视图(也可用item)
NSArray *array = [self.collectionViewindexPathsForVisibleSupplementaryElementsOfKind:UICollectionElementKindSectionHeader];
if ([[arrayfirstObject]section] ==0 || [[arrayfirstObject]section] ==1) {
NSIndexPath *tabIndexPath = [NSIndexPathindexPathForRow:0inSection:0];
[self.tableViewselectRowAtIndexPath:tabIndexPathanimated:NOscrollPosition:UITableViewScrollPositionNone];
[self.tableViewscrollToRowAtIndexPath:tabIndexPathatScrollPosition:UITableViewScrollPositionTopanimated:YES];
}
return;
}
NSIndexPath *tabIndexPath = [NSIndexPathindexPathForRow:indexPathNow.sectioninSection:0];
[self.tableViewselectRowAtIndexPath:tabIndexPathanimated:NOscrollPosition:UITableViewScrollPositionNone];
[self.tableViewscrollToRowAtIndexPath:tabIndexPathatScrollPosition:UITableViewScrollPositionTopanimated:YES];
}
}
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
if (scrollView ==self.collectionView) {
isGetWhatWay =YES;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
isGetWhatWay =NO;
NSIndexPath *index = [NSIndexPathindexPathForRow:0inSection:indexPath.row];
[self.collectionViewscrollToItemAtIndexPath:indexatScrollPosition:UICollectionViewScrollPositionCenteredVerticallyanimated:YES];
}
#warning 注册头视图
[_collectionViewregisterClass:[UICollectionReusableViewclass]forSupplementaryViewOfKind:UICollectionElementKindSectionHeaderwithReuseIdentifier:@"HeaderCollectionReusableView"];
[_collectionViewregisterClass:[UICollectionReusableViewclass]forSupplementaryViewOfKind:UICollectionElementKindSectionFooterwithReuseIdentifier:@"FooterCollectionReusableView"];
#pragma mark 返回头视图的高度
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
#pragma mark 返回尾视图的高度
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
- 实现tableView和collectionView的相互关联方法
- tableView和collectionView刷新的三种方法
- 关于collectionView和tableView的两种cell的出列方法的区别
- TableView 或者collectionView 获取点击的cell 和当前行数的方法
- iOS 导航和tableView/collectionView影响界面
- iOS 导航和tableView/collectionView影响界面
- CollectionView 与 TableView 的一些问题
- tableView//collectionView加载时的动画
- tableview或者collectionView列表滑动到顶部的三种方法
- iOS下用一行代码实现tableview(collectionview)的parallax效果
- iOS 类似于礼物说分类栏TableView,CollectionView联动的实现
- 使用tableView和CollectionView的时候需要注意的几点(单元格重用)
- 郑州iOS點 - 关于tableView 和 collectionView 在ReloadData时候闪烁的问题
- IOS中关于TableView必须实现的步骤和方法
- eBay和Paypal的相互关联
- TableView的属性和方法
- 实现collectionview加载到tableview的tableFooterView上一起滑动(类似淘宝购物车)--通过添加观察者实现
- collectionView中嵌套tableView
- C++开发人脸性别识别教程(10)——添加图片的人脸检测程序
- Java类集框架
- Java执行顺序
- 名侦探柯南(贪心问题)
- CodeForces 616B Dinner with Emma
- 实现tableView和collectionView的相互关联方法
- <LeetCode OJ> 141 / 142 Linked List Cycle(I / II)
- 行为型模式-状态模式state
- BeanUtils操作Bean的属性
- 实现应用Matrix旋转图像
- ElasticSearch path.home is not configured报错解决
- Qt程序界面美化一-- stylesheet
- Block和typedef
- vmstat