我試圖把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