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

相关推荐
Magnetic_h19 分钟前
【iOS】锁的原理
笔记·学习·macos·ios·objective-c·cocoa·xcode
Digitally2 小时前
将 iPhone 联系人转移到 Infinix 的完整指南
ios·cocoa·iphone
Cosmoshhhyyy12 小时前
mac环境下安装git并配置密钥等
git·macos
imLix16 小时前
RunLoop 实现原理
前端·ios
肥肥呀呀呀18 小时前
mac 安卓模拟器 blueStacks
macos
csdn_aspnet18 小时前
如何在 MacOS 上安装 SQL Server
macos·sqlserver
归辞...1 天前
「iOS」————设计架构
ios·架构
i紸定i1 天前
解决html-to-image在 ios 上dom里面的图片不显示出来
前端·ios·vue·html·html-to-image
YungFan2 天前
iOS26适配指南之UIButton
ios·swift
共享家95272 天前
linux-数据链路层
linux·网络·macos