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代理方法

相关推荐
songgeb14 小时前
YYImage Bug:一行之差,正常 JPEG 如何在 iOS 被读成条纹
ios·swift
fthux16 小时前
Tick Rest,一个休息提醒工具的自我修养
macos·开源·swift
茶底世界之下21 小时前
阴天花摊不必变暖:用 Awaking 留住花色与湿街
ios·app·产品
Fatbobman(东坡肘子)1 天前
快速消失的硬盘容量 -- 肘子的 Swift 周报 #160
开发语言·人工智能·redis·ios·swiftui·iphone·swift
FPGA小迷弟2 天前
FPGA 与千兆以太网:各类物理接口的形式、区别、使用方法与应用场景详解
tcp/ip·macos·fpga开发·udp·fpga
茶底世界之下2 天前
斜光下的旧自行车:用 Awaking 留一版复古胶片色
ios·app·产品
2501_916008892 天前
iPhone 设备信息查看,用 KeyMob 看型号、序列号、电池健康和 UDID
android·ios·小程序·https·uni-app·iphone·webview
茶底世界之下3 天前
iPhone Duo 适配实战,Awaking 踩过的 8 个坑
ios·swiftui·swift
跨境数据猎手3 天前
HTTP 响应体编码与压缩:识别、解码
网络协议·http·ios
也非非也3 天前
iPhone 中国区 AI 落地:Apple 与阿里千问合作的技术观察
大数据·人工智能·ios·agent·iphone·智子