标题说明了一切,我通常像这样打开ViewControllers
ListingViewController *listingView = [[ListingViewController alloc]init];
[self.navigationController pushViewController:listingView animated:YES];但是在这个特殊的类上,这是一个定制的UICollectionView单元,我想根据单击的单元来启动一个新的控制器。我怎么能这么做?
发布于 2014-07-10 08:57:49
通常的方法是在包含UICollectionViewDelegate的视图控制器中实现UICollectionView方法UICollectionView。然后,您可以以正常的方式呈现新的视图控制器。
例如:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
MyModel * model = self.listItems[indexPath.row]; //retrieve the object that is displayed by the cell at the selected index
MyViewerViewController * vc = [[MyViewerViewController alloc] initWithMyModel:model];
[self.navigationController pushViewController:vc animated:YES];
}发布于 2014-07-10 08:53:05
您希望将详细信息视图添加到单元格中,在添加详细视图.Hopefully上尝试此链接,这将有所帮助。
发布于 2014-07-10 09:06:35
使用UICollectionViewDelegate方法didSelectItemAtIndexPath进行此操作,并确保实现UICollectionView的视图控制器类中存在此委托方法。
https://stackoverflow.com/questions/24672121
复制相似问题