随笔 - 399,  文章 - 0,  评论 - 7,  阅读 - 21万

 

复制代码
    self.bgScrollView.bounces = NO;
///和后边bottomCellOffset 正好相反
    CGFloat maxH = (Screen_Height - self.bgScrollView.tableViewBottomFloat - Screen_NAV_Height ) * 0.7 - 20;
    CGFloat tempTableViewOffsetY = maxH;
    ///重新设置tv高度
    [self.bgScrollView.tableView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgScrollView.headerButton.mas_bottom);
        make.height.mas_equalTo(tempTableViewOffsetY);
        make.left.bottom.right.equalTo(self.carInfoView);
    }];
复制代码

 

 

/// table能不能滚动
@property (nonatomic, assign) BOOL canScroll; 
/// scroll能不能滚动
@property(assign, nonatomic) BOOL superCanScroll; 

 

自定义view 的init 方法 或者vc的viewDidLoad 方法

        self.canScroll = NO;
        self.superCanScroll = YES;

 

 

 

实现代理

/// 子视图滚动时候,同时响应滚动手势。
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}

 

复制代码
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{

    //tableView 滚动处理
    if (scrollView == self.tableView){
        NSLog(@"tabelview >>>>>>> 滚动 == %.2F",scrollView.contentOffset.y);

        if (!self.canScroll) {
            scrollView.contentOffset = CGPointZero;
        }
        if (scrollView.contentOffset.y < 0 ) {
            scrollView.contentOffset = CGPointZero;
            self.superCanScroll = YES;
            self.canScroll = NO;
        }
    }else{
        /*
         当 底层滚动式图滚动到指定位置时,
         停止滚动,开始滚动子视图
         20 :self.bgScrollView.headerButton 的高度
         10:底部bottom 高度
         */
//        CGFloat bottomCellOffset = (Screen_Height - self.tableViewBottomFloat - Screen_NAV_Height - 20) * 0.3;
//        CGFloat bottomCellOffset = (Screen_Height - self.tableViewBottomFloat - Screen_NAV_Height ) * 0.3 + 20;
        CGFloat bottomCellOffset = (Screen_Height - self.tableViewBottomFloat - Screen_NAV_Height ) * 0.3 + 10; ///这个是外边tableview的高度
        if (scrollView.contentOffset.y >= bottomCellOffset) {
            scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
            if (self.superCanScroll) {
                self.superCanScroll = NO;
                self.canScroll = YES;
            }
        }else{
            if (!self.superCanScroll) {//子视图没到顶部
                scrollView.contentOffset = CGPointMake(0, bottomCellOffset);
            }
        }
    }
}
复制代码

 

posted on   懂事长qingzZ  阅读(450)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
历史上的今天:
2019-10-18 MacOS Catalina 虚拟机VMware Fusion 重装教程 和问题

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示