首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iCarousel numberOfItemsInCarousel

iCarousel numberOfItemsInCarousel
EN

Stack Overflow用户
提问于 2016-10-18 08:30:37
回答 1查看 147关注 0票数 0

我在CollectionView中使用了CollectionView模块。旋转木马视图在我的UICollectionViewCell中。

我的代码如下。

代码语言:javascript
复制
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
}

}

错误消息如下所示

由于“NSInvalidArgumentException”异常终止应用程序,原因:'-NSObject numberOfItemsInCarousel::未识别的选择器发送到实例0x7f99bb3734a0‘

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

EN

回答 1

Stack Overflow用户

发布于 2016-10-21 08:54:41

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

编写这样的dealloc方法

代码语言:javascript
复制
- (void)dealloc{
    iCarouselView.delegate = nil
    iCarouselView.dataSource = nil
 }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40103276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档