【发布时间】:2015-04-20 07:42:16
【问题描述】:
所以我从 UITableView 切换到 UICollectionView。单元格都加载得很好,看起来很漂亮,但现在我不能再选择它们中的任何一个了。水龙头在日志中被识别,但它并没有把我带到它应该带我去的视图。
真正改变的唯一内容是您在“cellForItem”部分中看到的那些被注释掉的内容。其他一切都与它在 TableView 中工作时的情况相同。它只是应该将我带到您点击时指定的 ViewController。相反,轻拍被记录下来,但它什么也没做。任何帮助将不胜感激。
我也尝试摆脱 [collectionView deselectItemAtIndexPath:indexPath animated:YES];
...但没有任何区别。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
PlaceCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
// Configure the cell
//UINib * placeCell = [UINib nibWithNibName:@"Shops" bundle:nil];
// NSArray *topLevelItems = [placeCell instantiateWithOwner:self options:nil];
// cell = [topLevelItems objectAtIndex:0];
Place *p = [_entries objectAtIndex:indexPath.row];
cell.placeName.text = p.PName;
NSLog(@"p:%@",p.PName);
cell.placeName.textColor = [UIColor colorWithRed:3/255.0f green:6/255.0f blue:4/255.0f alpha:1.0f];
NSString *pIcon;
pIcon = typeName;
//NSLog(pIcon);
cell.placeImg.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:p.PImage]]];
NSLog(@"i:%@",p.PImage);
return cell;
}
-(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"Tap Recognized");
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
Place *p = [_entries objectAtIndex:indexPath.row];
DetailPlaceViewController * pvc = [[DetailPlaceViewController alloc] init];
[pvc setPlace:p];
[self.navigationController pushViewController:pvc animated:YES];
}
【问题讨论】:
标签: xcode uicollectionview didselectrowatindexpath