gpt4 book ai didi

ios - iCarousel numberOfItemsInCarousel

转载 作者:行者123 更新时间:2023-11-30 12:58:44 25 4
gpt4 key购买 nike

我在 CollectionView 中使用 iCarousel 模块。轮播 View 位于我的 UICollectionViewCell 中。

我的代码如下。

class CelebrityDetailHeaderCell: UICollectionViewCell, UITextFieldDelegate, SDCycleScrollViewDelegate, iCarouselDataSource, iCarouselDelegate {

@IBOutlet weak var backgroudLab: UILabel!
@IBOutlet weak var name_en: UILabel!
@IBOutlet weak var name_tw: UILabel!
@IBOutlet weak var intro: UILabel!
@IBOutlet weak var DetailImg: UIImageView!
@IBOutlet weak var iCarouselView: iCarousel!

let screenWidth = UIScreen.mainScreen().bounds.width
let screenHeight = UIScreen.mainScreen().bounds.height

override func awakeFromNib() {
super.awakeFromNib()

iCarouselView.delegate = self
iCarouselView.dataSource = self

iCarouselView.type = .Linear
}

func numberOfItemsInCarousel(carousel: iCarousel) -> Int {
return 1
}
func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView {
let tempView = UIView(frame: CGRect(x: 0, y: screenWidth/2, width: screenWidth, height: screenWidth/2))
tempView.backgroundColor = UIColor.redColor()
return tempView
}
func carousel(carousel: iCarousel, valueForOption option: iCarouselOption, withDefault value: CGFloat) -> CGFloat {
if option == iCarouselOption.Spacing {
return 1.2
}
return value
}

}

错误信息如下

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSObject numberOfItemsInCarousel:]: unrecognized selector sent to instance 0x7f99bb3734a0'

我已经设置了 numberOfItemsInCarousel 为什么错误消息显示这个。有人帮助我吗?谢谢。

最佳答案

看来您需要在单元格中添加一个 dealloc 方法。当您的单元格被解除分配并且 iCarousel 委托(delegate)正在调用该方法到某个已解除分配的实例时,这就是它崩溃的原因

编写这样的dealloc方法

- (void)dealloc{
iCarouselView.delegate = nil
iCarouselView.dataSource = nil
}

关于ios - iCarousel numberOfItemsInCarousel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40103276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com