【发布时间】:2019-02-13 00:58:09
【问题描述】:
我有这个错误。
无法使用“CGFloat”类型的索引为“[UIImage]”类型的值下标
为什么会这样?
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if(scrollView.contentOffset.y > self.view.frame.height) {
//(1/10) because we are changing the scrollView every 1/10 of the screen
let pictureCount = scrollView.contentOffset.y/scrollView.frame.height*(1/10)
imageView.image = images[pictureCount]
}
}
【问题讨论】:
-
imageView.image = images[Int(pictureCount)]将 CGFloat 转换为 Int 以访问具有索引的数组。