Error[8]: Undefined offset: 8, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在尝试使用UICollectionView来显示在UI ImageView中具有动画GIF的方形MyCollectionViewCell. 行和部分设置如下: override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return 1}override fun 我正在尝试使用UICollectionVIEw来显示在UI ImageVIEw中具有动画GIF的方形MyCollectionVIEwCell.

行和部分设置如下:

overrIDe func numberOfSectionsInCollectionVIEw(collectionVIEw: UICollectionVIEw) -> Int {    return 1}overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,numberOfItemsInSection section: Int) -> Int {    return 50}

我正在使用SwiftGif将GIF分配给单元格的UIImageVIEw,如下所示:

let gifs = [UIImage.gifWithname("gif1"),UIImage.gifWithname("gif2"),UIImage.gifWithname("gif3")]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionVIEwCell {    let cell = collectionVIEw.dequeueReusableCellWithReuseIDentifIEr("gifCell",forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = gifs[indexPath.item % gifs.count]    return cell}

大部分的一切都很有效.但我的问题是,在滚动时,有时候单元格是空白而没有出现GIF.在调试过程中,我已经向单元格添加了一个标签来显示indexPath.item,正如您在上面的代码中所看到的,以确保单元格没有被传递并且发现标签将始终显示indexPath即使单元格不显示GIF.

我已使用常规图像进行测试,如下所示:

let testimages = [UIImage(named: "testimage1"),UIImage(named: "testimage2",UIImage(named: "testimage3")]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = testimages[indexPath.item % testimages.count]    return cell}

并且没有出现空白细胞.

更奇怪的是,当我最初在collectionVIEw(… cellForItemAtIndexPath)中实际构建GIF时,我没有遇到空白单元格的任何问题:

let gifnames = ["gif1","gif2","gif3"]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,forIndexPath: indexPath) as! GifCollectionVIEwCell    let gif = UIImage.gifWithname(gifnames[indexPath.item % gifnames.count])    cell.gifImageVIEw.image = gif    return cell}

如果不是因为GIF构建过程对UICollectionVIEw的滚动性能产生巨大影响,这就迫使我首先改变实现,这个原始实现会起作用.

我已经确认这不是SwiftGif的问题,因为我在一个不同的应用程序中使用动画渲染库和AnimatedVIEw代替MyCollectionVIEwCell中的UIImageVIEw复制了这个问题并显示了动画而不是GIF并且随机细胞也遇到了同样的问题在滚动CollectionVIEw时,不显示任何内容而不显示动画.

我尝试过StackOverflow解决方案here并实现了一个自定义UICollectionVIEwFlowLayout,如下所示:

class MyFlowLayout: UICollectionVIEwFlowLayout {    overrIDe func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionVIEwLayoutAttributes]? {        let attributes = super.layoutAttributesForElementsInRect(rect)        let contentSize = self.collectionVIEwContentSize()        let newAttrs = attributes?.filter { 
self.collectionVIEw?.collectionVIEwLayout = MyFlowLayout()
.frame.maxX <= contentSize.wIDth &&
overrIDe func shouldInvalIDateLayoutForBoundsChange(newBounds: CGRect) -> Bool {    return true}
.frame.maxY <= contentSize.height} return newAttrs }}

并在vIEwDIDLoad()中分配它,如下所示:

overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionVIEwCell {            let cell = collectionVIEw.dequeueReusableCellWithReuseIDentifIEr("gifCell",forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = nil    // Added this line    cell.gifImageVIEw.image = gifs[indexPath.item % gifs.count]    cell.infolabel.text = String(indexPath.item)    return cell}

在MyFlowLayout中我也尝试过:

[+++]

我也搞乱了各种单元格大小(宽度1小于高度,高度1小于宽度等)并且与一些插入组合混乱,但未设法找到导致动画视图不到的此问题的来源出现.

任何帮助,将不胜感激.谢谢

解决方法 我在分配图像之前通过在collectionVIEw(… cellForItemAtIndexPath)中设置gifImageVIEw.image = nil解决了这个问题.

[+++]

不确定如何/为什么这个修复它但它现在有效.

总结

以上是内存溢出为你收集整理的ios – Swift UICollectionViewCell动画视图在滚动时随机空白全部内容,希望文章能够帮你解决ios – Swift UICollectionViewCell动画视图在滚动时随机空白所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 9, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在尝试使用UICollectionView来显示在UI ImageView中具有动画GIF的方形MyCollectionViewCell. 行和部分设置如下: override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return 1}override fun 我正在尝试使用UICollectionVIEw来显示在UI ImageVIEw中具有动画GIF的方形MyCollectionVIEwCell.

行和部分设置如下:

overrIDe func numberOfSectionsInCollectionVIEw(collectionVIEw: UICollectionVIEw) -> Int {    return 1}overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,numberOfItemsInSection section: Int) -> Int {    return 50}

我正在使用SwiftGif将GIF分配给单元格的UIImageVIEw,如下所示:

let gifs = [UIImage.gifWithname("gif1"),UIImage.gifWithname("gif2"),UIImage.gifWithname("gif3")]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionVIEwCell {    let cell = collectionVIEw.dequeueReusableCellWithReuseIDentifIEr("gifCell",forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = gifs[indexPath.item % gifs.count]    return cell}

大部分的一切都很有效.但我的问题是,在滚动时,有时候单元格是空白而没有出现GIF.在调试过程中,我已经向单元格添加了一个标签来显示indexPath.item,正如您在上面的代码中所看到的,以确保单元格没有被传递并且发现标签将始终显示indexPath即使单元格不显示GIF.

我已使用常规图像进行测试,如下所示:

let testimages = [UIImage(named: "testimage1"),UIImage(named: "testimage2",UIImage(named: "testimage3")]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = testimages[indexPath.item % testimages.count]    return cell}

并且没有出现空白细胞.

更奇怪的是,当我最初在collectionVIEw(… cellForItemAtIndexPath)中实际构建GIF时,我没有遇到空白单元格的任何问题:

let gifnames = ["gif1","gif2","gif3"]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,forIndexPath: indexPath) as! GifCollectionVIEwCell    let gif = UIImage.gifWithname(gifnames[indexPath.item % gifnames.count])    cell.gifImageVIEw.image = gif    return cell}

如果不是因为GIF构建过程对UICollectionVIEw的滚动性能产生巨大影响,这就迫使我首先改变实现,这个原始实现会起作用.

我已经确认这不是SwiftGif的问题,因为我在一个不同的应用程序中使用动画渲染库和AnimatedVIEw代替MyCollectionVIEwCell中的UIImageVIEw复制了这个问题并显示了动画而不是GIF并且随机细胞也遇到了同样的问题在滚动CollectionVIEw时,不显示任何内容而不显示动画.

我尝试过StackOverflow解决方案here并实现了一个自定义UICollectionVIEwFlowLayout,如下所示:

class MyFlowLayout: UICollectionVIEwFlowLayout {    overrIDe func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionVIEwLayoutAttributes]? {        let attributes = super.layoutAttributesForElementsInRect(rect)        let contentSize = self.collectionVIEwContentSize()        let newAttrs = attributes?.filter { 
self.collectionVIEw?.collectionVIEwLayout = MyFlowLayout()
.frame.maxX <= contentSize.wIDth &&
overrIDe func shouldInvalIDateLayoutForBoundsChange(newBounds: CGRect) -> Bool {    return true}
.frame.maxY <= contentSize.height} return newAttrs }}

并在vIEwDIDLoad()中分配它,如下所示:

overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionVIEwCell {            let cell = collectionVIEw.dequeueReusableCellWithReuseIDentifIEr("gifCell",forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = nil    // Added this line    cell.gifImageVIEw.image = gifs[indexPath.item % gifs.count]    cell.infolabel.text = String(indexPath.item)    return cell}

在MyFlowLayout中我也尝试过:

我也搞乱了各种单元格大小(宽度1小于高度,高度1小于宽度等)并且与一些插入组合混乱,但未设法找到导致动画视图不到的此问题的来源出现.

任何帮助,将不胜感激.谢谢

解决方法 我在分配图像之前通过在collectionVIEw(… cellForItemAtIndexPath)中设置gifImageVIEw.image = nil解决了这个问题.

[+++]

不确定如何/为什么这个修复它但它现在有效.

总结

以上是内存溢出为你收集整理的ios – Swift UICollectionViewCell动画视图在滚动时随机空白全部内容,希望文章能够帮你解决ios – Swift UICollectionViewCell动画视图在滚动时随机空白所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
ios – Swift UICollectionViewCell动画视图在滚动时随机空白_app_内存溢出

ios – Swift UICollectionViewCell动画视图在滚动时随机空白

ios – Swift UICollectionViewCell动画视图在滚动时随机空白,第1张

概述我正在尝试使用UICollectionView来显示在UI ImageView中具有动画GIF的方形MyCollectionViewCell. 行和部分设置如下: override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { return 1}override fun 我正在尝试使用UICollectionVIEw来显示在UI ImageVIEw中具有动画GIF的方形MyCollectionVIEwCell.

行和部分设置如下:

overrIDe func numberOfSectionsInCollectionVIEw(collectionVIEw: UICollectionVIEw) -> Int {    return 1}overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,numberOfItemsInSection section: Int) -> Int {    return 50}

我正在使用SwiftGif将GIF分配给单元格的UIImageVIEw,如下所示:

let gifs = [UIImage.gifWithname("gif1"),UIImage.gifWithname("gif2"),UIImage.gifWithname("gif3")]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionVIEwCell {    let cell = collectionVIEw.dequeueReusableCellWithReuseIDentifIEr("gifCell",forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = gifs[indexPath.item % gifs.count]    return cell}

大部分的一切都很有效.但我的问题是,在滚动时,有时候单元格是空白而没有出现GIF.在调试过程中,我已经向单元格添加了一个标签来显示indexPath.item,正如您在上面的代码中所看到的,以确保单元格没有被传递并且发现标签将始终显示indexPath即使单元格不显示GIF.

我已使用常规图像进行测试,如下所示:

let testimages = [UIImage(named: "testimage1"),UIImage(named: "testimage2",UIImage(named: "testimage3")]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = testimages[indexPath.item % testimages.count]    return cell}

并且没有出现空白细胞.

更奇怪的是,当我最初在collectionVIEw(… cellForItemAtIndexPath)中实际构建GIF时,我没有遇到空白单元格的任何问题:

let gifnames = ["gif1","gif2","gif3"]overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,forIndexPath: indexPath) as! GifCollectionVIEwCell    let gif = UIImage.gifWithname(gifnames[indexPath.item % gifnames.count])    cell.gifImageVIEw.image = gif    return cell}

如果不是因为GIF构建过程对UICollectionVIEw的滚动性能产生巨大影响,这就迫使我首先改变实现,这个原始实现会起作用.

我已经确认这不是SwiftGif的问题,因为我在一个不同的应用程序中使用动画渲染库和AnimatedVIEw代替MyCollectionVIEwCell中的UIImageVIEw复制了这个问题并显示了动画而不是GIF并且随机细胞也遇到了同样的问题在滚动CollectionVIEw时,不显示任何内容而不显示动画.

我尝试过StackOverflow解决方案here并实现了一个自定义UICollectionVIEwFlowLayout,如下所示:

class MyFlowLayout: UICollectionVIEwFlowLayout {    overrIDe func layoutAttributesForElementsInRect(rect: CGRect) -> [UICollectionVIEwLayoutAttributes]? {        let attributes = super.layoutAttributesForElementsInRect(rect)        let contentSize = self.collectionVIEwContentSize()        let newAttrs = attributes?.filter { 
self.collectionVIEw?.collectionVIEwLayout = MyFlowLayout()
.frame.maxX <= contentSize.wIDth &&
overrIDe func shouldInvalIDateLayoutForBoundsChange(newBounds: CGRect) -> Bool {    return true}
.frame.maxY <= contentSize.height} return newAttrs }}

并在vIEwDIDLoad()中分配它,如下所示:

overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionVIEwCell {            let cell = collectionVIEw.dequeueReusableCellWithReuseIDentifIEr("gifCell",forIndexPath: indexPath) as! GifCollectionVIEwCell    cell.gifImageVIEw.image = nil    // Added this line    cell.gifImageVIEw.image = gifs[indexPath.item % gifs.count]    cell.infolabel.text = String(indexPath.item)    return cell}

在MyFlowLayout中我也尝试过:

我也搞乱了各种单元格大小(宽度1小于高度,高度1小于宽度等)并且与一些插入组合混乱,但未设法找到导致动画视图不到的此问题的来源出现.

任何帮助,将不胜感激.谢谢

解决方法 我在分配图像之前通过在collectionVIEw(… cellForItemAtIndexPath)中设置gifImageVIEw.image = nil解决了这个问题.

不确定如何/为什么这个修复它但它现在有效.

总结

以上是内存溢出为你收集整理的ios – Swift UICollectionViewCell动画视图在滚动时随机空白全部内容,希望文章能够帮你解决ios – Swift UICollectionViewCell动画视图在滚动时随机空白所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1002990.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存