0
UICollectionView
의 메뉴를 만들려고합니다.UICollectionView의 메뉴 만들기
셀을 눌러 새로운보기 컨트롤러에 연결하려고합니다.
여기 내 코드는 있지만 오류는 발생하지 않지만 앱이 다운됩니다. 모든 도움을
2015-01-09 17:21:15.763 EventAPP[385:22587] -[UICollectionViewCell titleLabel]: unrecognized selector sent to instance 0x13ce16310
2015-01-09 17:21:15.765 EventAPP[385:22587] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewCell titleLabel]: unrecognized selector sent to instance 0x13ce16310'
*** First throw call stack:
(0x1869c259c 0x1971200e4 0x1869c9664 0x1869c6418 0x1868cab6c 0x10003009c 0x18b1d7bd0 0x18b1d5d30 0x18b1d16d4 0x18b171648 0x18aac9994 0x18aac4564 0x18aac4408 0x18aac3c08 0x18aac398c 0x18aabd3bc 0x18697aa50 0x1869779dc 0x186977dbc 0x1868a50a4 0x18fa475a4 0x18b1da3c0 0x10003231c 0x19778ea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
감사 :
#import "partnerViewController.h"
#import "CVCell.h"
@interface partnerViewController()
@property (strong,nonatomic) IBOutlet UICollectionView *collectionView;
@end
@implementation partnerViewController {
NSArray *menuArray;
}
(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
menuArray = [NSArray arrayWithObjects:@"HP",@"PureStorage",@"NimbleStorage",@"ExaGrid",@"CommVault",@"Zerto",@"Veeam",@"Coraid",@"Symantec", nil];
[self.collectionView registerClass:[CVCell class] forCellWithReuseIdentifier:@"cvCell"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [menuArray count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier;
if (indexPath.row == 0) {
cellIdentifier = @"0";
} else if(indexPath.row == 1) {
cellIdentifier = @"1";
} else if(indexPath.row == 1) {
cellIdentifier = @"2";
} else if(indexPath.row == 1) {
cellIdentifier = @"3";
} else if(indexPath.row == 1) {
cellIdentifier = @"4";
} else if(indexPath.row == 1) {
cellIdentifier = @"5";
} else if(indexPath.row == 1) {
cellIdentifier = @"6";
} else if(indexPath.row == 1) {
cellIdentifier = @"7";
} else if(indexPath.row == 1) {
cellIdentifier = @"8";
}
CVCell *cell = (CVCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
[self.collectionView registerClass:[cell class] forCellWithReuseIdentifier:@"cvCell"];
[cell.titleLabel setText:[menuArray objectAtIndex:indexPath.row]];
[cell.layer setBorderWidth:2.0f];
[cell.layer setBorderColor:[UIColor whiteColor].CGColor];
return cell;
}
@end
이
는 오류가 내가 얻을 수있다.CVCell *cell = (CVCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
을하지만 당신은 거짓말 :
CVCell 는 사용자 지정 셀이며 .m 및 .h 파일을 소유하고 있습니다. 식별자는 인터페이스에 설정됩니다. 은 타격을받을 때 멈추는 것처럼 보입니다. [cell.titleLabel setText : [menuArray objectAtIndex : indexPath.row]]; –
CVCell이 무엇인지 압니다 (추측 할 수 있습니다). 당신은 충돌의 의미를 물었습니다. 내가 말 했잖아. 이것은 CVCell이 아니며 크래시가이를 알려줍니다. 이제는 CVCell이 아닌 이유를 알아야합니다. 나는 당신에게 최고의 추측을했지만, 당신의 코드/스토리 보드를 볼 수 없으며 당신은 더 이상의 정보를주지 않았다. 나는 당신이 물어 온 질문에 완전히 대답했다. 나는 그 충돌에 대해 설명했고 나는 그것을 올바르게 설명했다고 믿는다. – matt