所以我试着用 iCarousel 创建一个简单的自动 ScrollView 。
我制作了 4 个 View ,中间的图像可见, 使用
func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView
并记录当前呈现的索引 View ,
我在 ipod touch/iphone 5/iphone 6 上测试它,每个 View 都在打印日志时呈现
current index rendered 0
current index rendered 3
current index rendered 2
current index rendered 1
但是当我在 iPhone 6+ 上尝试时,日志只打印:
current index rendered 0
current index rendered 3
current index rendered 1
只是旋转木马吗?我对此表示怀疑.. 这就是为什么,我应该怎么做才能使轮播呈现第三 View (2)?
因为在 func numberOfItemsInCarousel(carousel: iCarousel) -> Int
上,我返回图像数组的计数。
谢谢
最佳答案
抱歉,这似乎是重用 View 轮播的自然行为。 当它在5或6时, View 的维度允许它在初始化时全部渲染,因此不需要重用 View 。 但是当它在 6+ 时,尺寸更大,它使轮播仅呈现 3 个项目:当前、前/右和后/左(如果启用了环绕,并且启用了我的设置)
然后我开始意识到我在重用 View 时做错了。 我之前所做的是获取 UI 组件,然后重新创建它们的矩形。 而示例没有这样做。
所以我的解决方案是不重新创建矩形,只更改 subview 的 UIViewImage 的图像属性
关于ios - iCarousel 不在 iPhone 6+ 上呈现 4 个项目的第 3 个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36716125/