iOS UIScrollView的一个特性

1如果UIScrollView 的contentSize.height >

scrollView.bounds.size.height - scrollView.contentInset.top - scrollView.contentInset.bottom

, 则scrollView就可以滚动,否则无法滚动

并且最大的滚动范围就是 contentSize.height - (

scrollView.bounds.size.height - scrollView.contentInset.top - scrollView.contentInset.bottom

这里说的是自然滚动,就是在用户松手的情况下

能滚动的最大范围

并且,我们通过代码 uiscrollView setContentOffset:animated:YES

或者 uiscrollView setContentOffset:cgpointmake设置的

都只能是自动滚动能达到的位置,即 在contentSize.height - (

scrollView.bounds.size.height - scrollView.contentInset.top - scrollView.contentInset.bottom)之内,否则即使设置了,也会因为

contentSize不够而导致失败

2

两个滚动方法的不同

复制代码
[uiscrollView setContentOffset:animated:YES]

会出发scrollView 的 scrollViewDidScroll代理方法

复制代码
[uiView animatedwithduration:0.2 animated:^{
[uiscrollView setContentOffset:animated:NO]
}];

不会触发scrollViewDidScroll代理方法

相关推荐
EXI-小洲19 分钟前
MacOS IDEA将本地项目代码上传至SVN空仓库
macos·svn·intellij-idea
jike_20262 小时前
销售拜访记录APP推荐:客户沟通内容怎么快速整理?
ios·语音识别·iphone
00后程序员张5 小时前
iOS 开发全流程需要哪些工具?编码、调试、构建、发布阶段选择
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
游戏开发爱好者816 小时前
WebSocket 抓包怎么查看内容?从握手到消息帧完整解读
网络协议·计算机网络·网络安全·ios·adb·https·udp
悟空瞎说19 小时前
# Alamofire 使用文档 完整翻译
ios
weixin_531670891 天前
Interlude起来:久坐提醒软件为什么需要登录?有没有完全本地运行的Mac休息提醒软件?
人工智能·macos·swift
WeiAreYoung1 天前
Flutter+iOS 实现 Live Activity
flutter·ios
2501_916008891 天前
Swift多环境配置:利用Scheme实现灵活的多环境管理
开发语言·ide·vscode·ios·个人开发·swift·敏捷流程
00后程序员张1 天前
Windows / Linux / Mac 上不用 Xcode 把 IPA 上传到 App Store,upload 命令详解
android·ios·小程序·https·uni-app·iphone·webview