2014-10-17 8 views
0

서브 클래스가 UICollectionViewCell이고 배경색이 UIView 인 하위 클래스 만 표시되어 현재 있음을 나타냅니다. XIB에서로드하기 위해XIB에서로드 할 때 UICollectionViewCell에서 충돌이 발생합니다.

, 나는이를 교체해야이와

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self.localPlayerItemsView registerClass:[MBTradeCollectionViewCell class] 
        forCellWithReuseIdentifier:CellIdentifier]; 
} 

:

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    UINib *nib = [UINib nibWithNibName:@"MBTradeCollectionViewCell" bundle:nil]; 

    [self.localPlayerItemsView registerNib:nib forCellWithReuseIdentifier:CellIdentifier]; 
} 

그렇게되면, 그때 collectionView:cellForItemAtIndexPath:의 첫 번째 줄에 충돌을 얻을 :

012 : 여기
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 
    MBTradeCollectionViewCell *aCell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier 
                       forIndexPath:indexPath]; 

    return aCell; 
} 

는 충돌의
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x7d461780> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key itemCountView.' 

registerClass:forCellWithReuseIdentifier:을 사용할 때이 크래시가 발생하지 않지만 내 xib가로드되지 않습니다.

+0

itemCountView에 대한 사용자 정의 셀 콘센트 연결을 확인하십시오. – BhushanVU

+0

IBOutlet과 같은 소리가 잘못 연결됩니다. 펜촉의 모든 연결을 확인하십시오. – Rayfleck

+0

[이게 무슨 뜻입니까? " 'NSUnknownKeyException', 이유 : ...이 클래스는 키 값 X와 호환되는 키 값이 아닙니다."] (http://stackoverflow.com/questions/3088059/what-does-this-mean-nsunknownkeyexception-reason- 이 클래스는 키가 아니다) –

답변

3

이 충돌은 일반적으로 콘센트가 고장 났을 때 발생합니다. nib 파일의 이름이 itemCountView 인 콘센트가 깨져서 제대로 연결되지 않았는지 확인하십시오. 빨간색 표시가 나타납니다.

3

MBTradeCollectionViewCell xib 파일에서 파일 소유자와 관련된 내용을 변경하지 마십시오. top most view의 클래스를 MBTradeCollectionViewCell로 변경하고 itemCountView을 선택하고 top most view에 연결합니다. 희망이 문제를 해결할 것입니다.

1

수정했습니다.

보조 모드로 들어가서 속성에서 IB로 드래그하여 '파일 소유자'또는 '거래 수집보기'옵션을 제공 했습니까?

맨 아래 하나를 선택했는데, 이는 파일 소유자에게 연결되지 않았 음을 의미합니다.하지만 거래 내역보기에서도 볼 수 있다는 것을 알게되었습니다.

그리고 작동합니다.

관련 문제