iOS ~ 在一个UITableView中,headerView

2022-05-20  本文已影响0人  阳光下的叶子呵

原理:
方法:-(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)];
}
上一篇 下一篇

猜你喜欢

热点阅读