swift - ImageView frame is not changing while scrolling in Xcode 11.0 (11A420a)
问题描述
I have a UIView on top of another UIView. In that top view I have a UIImageView and on top of that there is a scrollVIew. When scrolling it used to stretch the imageView frame calculating the scroll offset. Now updating to Xcode 11.0 (11A420a) this feature is not working even though nothing has changed. Any suggestion why ? Here is my imageView constraints:
and my scrollViewDidScroll function:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let y = 135 - (self.scrollView.contentOffset.y + 135)
let h = max(120, 160 + y)
let rect = CGRect(x: 0, y: 0, width: view.bounds.width, height: h)
NHBannerImageView.frame = rect
}
As you can see there is a rect variable which value changes depending on scroll but after that image frame is not changing.
I have downloaded the Xcode 10.3 and its working straight away, with the same configuration.
解决方案
Update your view layout might be solve this problem. Add -
self.view.layoutIfNeeded()
in scrollViewDidScroll
推荐阅读
- reactjs - 嵌套应用程序的 IIS URL 重写
- javascript - 在 Chrome 和 Firefox 中调整图像大小时 contenteditable="true" 属性不适用于图像标签的解决方案
- python - PyPDF2.utils.PdfReadError:文件尚未解密
- java - 使用 SceneBuilder 在 JavaFX 项目开始时调用函数
- c++ - 谁能解释这个图像分辨率设置代码?到底发生了什么
- java - 在阻止模式下拨打电话
- c++ - 如何使用 Fast-LZMA2 压缩/解压缩缓冲区
- python - Anaconda导入错误,循环导入错误
- flutter - 没有为“DocumentReference”类型定义获取器“documentID”
- android - BasicNetwork.performRequest:带有 Volley 库的 newsapi.org 的意外响应代码 403