当我运行我的应用程序时,我发现了一个信号 SIGABRT 线程。这是错误消息:[__NSCFConstantString _isResizable]: unrecognized selector sent to instance 0x5c20
问题来自 [[self myCollectionView]setDataSource:self]; 因为当我评论它时它消失了。
据我了解, myCollectionView 数据源的类型和 self 不一样。这就是为什么我有我的错误。
谢谢你的帮助
皮埃尔
CalViewController.h
#import <UIKit/UIKit.h>
@interface CalViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate>
@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView;
@end
CalViewController.m
#import "CalViewController.h"
#import "CustomCell.h"
@interface CalViewController ()
{
NSArray *arrayOfImages;
NSArray *arrayOfDescriptions;
}
@end
@implementation CalViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[[self myCollectionView]setDataSource:self];
[[self myCollectionView]setDelegate:self];
arrayOfImages = [[NSArray alloc]initWithObjects:@"chibre.jpg",nil];
arrayOfDescriptions =[[NSArray alloc]initWithObjects:@"Test",nil];
}
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [arrayOfDescriptions count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"Cell";
CustomCell *cell = ([collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath]);
[[cell myImage]setImage:[arrayOfImages objectAtIndex:indexPath.item]];
[[cell myDescriptionLabel]setText:[arrayOfDescriptions objectAtIndex:indexPath.item]];
return cell;
}
- (NSInteger)numberOfSections:(UICollectionView *) collectionView
{return 1;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end