2015-10-13 91 views
0

我想推動下一個控制器,但不成功,我該怎麼辦?collectionView,didSelectItemAtIndexPath一些問題

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; 

    NSInteger section = indexPath.section, row = indexPath.row; 

if (section == 1) { 

     if (row == 0) { 

      DetailsViewController * DetailsVC = [DetailsViewController alloc]init]; 

      [self.navigationController pushViewController: DetailsVC animated:YES]; 
     } else if (row == 1) { 
       } 
    } else if 
(section == 2) { 

    } 

} 

enter image description here

回答

0

你必須爲視圖控制器設置標識符和調用方法類似

CallViewController *vc=[self.storyboard instantiateViewControllerWithIdentifier:@"CallViewController"]; 

[self.navigationController pushViewController:vc animated:YES]; 

,並確保您嵌入了導航視圖控制器。

+0

感謝您的幫助。 – runsheng0324