美文网首页
iOS ~ 在一个UITableView中,headerView

iOS ~ 在一个UITableView中,headerView

作者: 阳光下的叶子呵 | 来源:发表于2022-05-20 19:44 被阅读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)];
}

相关文章

网友评论

      本文标题:iOS ~ 在一个UITableView中,headerView

      本文链接:https://www.haomeiwen.com/subject/ogtqprtx.html