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); } } } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
2019-10-18 MacOS Catalina 虚拟机VMware Fusion 重装教程 和问题