【发布时间】:2014-10-26 07:54:07
【问题描述】:
我正在将数据发送到集合视图,但我收到错误 [__NSCFConstantString objectAtIndex:]: unrecognized selector sent to instance. 请帮助我。谢谢。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
// NSURL *imageURL = [NSURL URLWithString:str1];
// NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
// UIImage *image = [UIImage imageWithData:imageData];
// thumbnailImgView.image = image;
static NSString *identifier = @"Cell";
CustomCell *cell = (CustomCell *)[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
UIImageView *recipeImageView = (UIImageView *)[cell viewWithTag:100];
recipeImageView.image = [UIImage imageNamed:[recipeImages[indexPath.section] objectAtIndex:indexPath.row]];
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img.png"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"One-Album.png"]];
return cell;
}
【问题讨论】:
-
你能告诉我你正在填充
recipeImages的代码吗? -
- (void)viewDidLoad { [super viewDidLoad]; recipeImages = [NSArray arrayWithObjects:@"img.png", @"One-Album.png", @"Create-Album.png", @"AllPhotos.png", @"Albums.png", @"brightness1.png ", @"original1 (1).png", @"crop1.png", nil]; // 加载视图后做任何额外的设置。 }
-
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return [recipeImages count]; }
-
请编辑问题。
-
我在这一行遇到错误。 recipeImageView.image = [UIImage imageNamed:[recipeImages[indexPath.section] objectAtIndex:indexPath.row]];
标签: ios objective-c iphone ios7 uicollectionview