2016-10-18 2 views
0

iCarousel 모듈을 CollectionView에 사용합니다. Carousel View는 UICollectionViewCell에 있습니다.iCarousel numberOfItemsInCarousel

내 코드는 다음과 같습니다.

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을 설정했는데 오류 메시지가이를 나타 냈습니다. 누구가 나를 도울까요? 감사.

+0

같은 할당 해제의 방법을 쓰기 충돌되는 이유 iCarousel의 대표는 일부 할당이 해제 된 인스턴스에 그 방법을 먹으 렴 호출 'numberOfItemsInCarousel :'을 호출하지만'CelebrityDetailVC' 객체는 호출하지 않습니다. – Larme

+0

iCarousel을 collectionviewcell에 추가하는 방법은 무엇입니까? –

답변

0

세포에 dealloc 메서드를 추가해야합니다. 휴대가 할당 해제지고 어딘가에는 지시를받을 "NSObject의"개체이기 때문에

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

작동하지 않았습니다. –