原理:
方法:-(void)scrollViewDidScroll:(UIScrollView *)scrollView
headerView代码:
#pragma mark -- -- 同步滑动 NotificationCenter
//通知其他cell 滑动了
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSDictionary*info = @{@"GW_FullAcreen_ActualGameContentCellOffsetX":@(scrollView.contentOffset.x)};
[[NSNotificationCenter defaultCenter] postNotificationName:@"GW_FullAcreen_ActualGameContentCellOffsetX" object:nil userInfo:info];
}
//接收其他cell的滑动
-(void)addNotification {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cellhuadong:) name:@"GW_FullAcreen_ActualGameContentCellOffsetX" object:nil];
}
-(void)cellhuadong:(NSNotification *)note{
NSDictionary *info = note.userInfo;
[_scorecardCollectionView setContentOffset:CGPointMake([info[@"GW_FullAcreen_ActualGameContentCellOffsetX"] floatValue], 0)];
}
cell 代码:
#pragma mark - NotificationCenter
//通知其他cell 滑动了
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSDictionary*info = @{@"GW_FullAcreen_ActualGameContentCellOffsetX":@(scrollView.contentOffset.x)};
[[NSNotificationCenter defaultCenter] postNotificationName:@"GW_FullAcreen_ActualGameContentCellOffsetX" object:nil userInfo:info];
}
//接收其他cell的滑动
-(void)addNotification {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cellhuadong:) name:@"GW_FullAcreen_ActualGameContentCellOffsetX" object:nil];
}
-(void)cellhuadong:(NSNotification *)note{
NSDictionary *info = note.userInfo;
[_parCollectionView setContentOffset:CGPointMake([info[@"GW_FullAcreen_ActualGameContentCellOffsetX"] floatValue], 0)];
[_numberCollectionView setContentOffset:CGPointMake([info[@"GW_FullAcreen_ActualGameContentCellOffsetX"] floatValue], 0)];
}







网友评论