[英]xcode UICollection View opening another view controller
我有一個UICollectionViewController並且已經在單元格中顯示圖像,因為我點擊/點擊特定圖像,“推送”到普通的ViewController。 我怎么做? 這是我到目前為止的代碼...想在其他視圖控制器中打開所選圖像,請幫忙
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [imagearray count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier=@"Cell" ;
customcell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
[[cell nyimage]setImage:[UIImage imageNamed:[imagearray objectAtIndex:indexPath.item]]];
return cell;
}
您可以像這樣實現委托方法:
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController* viewController = [[DetailViewController alloc] init];
//configure detail view controller
// viewController.detailInfo = ...
[self.navigationController pushViewController:viewController animated:YES];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.