我试图把UICollectionview放在扩展的uitableviewcell内,但我不断收到错误。 collectionview也可以拍照并将其存储在collectionview中。我用这个代码:我怎样才能以扩展uitableviewcell内置uicollectionview
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath (NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"myCell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
[cell addTarget:self action:@selector(uploadPicture:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
- (void)uploadPicture:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
我得到的错误是“为UICollectionViewCell没有明显的@interface声明selelctor addTarget:动作:forControlEvents”在第4行和第5行“无效的方法应该没有返回值”和第11行“不可见@interface为ExpandingCell声明了选择器presentViewController:animated:completion”
我很盼望在这一点上的帮助。所以如果你有帮助,提前谢谢你。
你检查过文件吗? – Andy 2014-12-03 01:41:37
是的,这没有帮助。 – Tstac4 2014-12-03 01:49:40
你是如何知道addTarget方法的?它不在UICollectionViewCell的文档中。 – Andy 2014-12-03 01:58:08