2

I try to present viewController(BrandViewController) from view(MainCollectionViewCell.m) by using didselectItemAt method. So,

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
        UIViewController *currentTopVC = [self currentTopViewController];
        BrandViewController *brandVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"BrandVC"];

        [currentTopVC presentViewController:brandVC animated:true completion:nil];
}

- (UIViewController *)currentTopViewController {
    UIViewController *topVC = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
    while (topVC.presentedViewController) {
        topVC = topVC.presentedViewController;
    }
    return topVC;
}

This code shows BrandViewController correctly, but I cannot click any buttons or images from BrandViewControllerexcept my back button. Can you give me any ideas about this problem?


edited : I have two collectionViews. One is in MainViewController(MainCollectionView), and the other is inside of MainCollectionViewCell(didSelectItemAt method called from here).

edited2: presented View hierarchy has two UITransitionView

enter image description here

Changnam Hong
  • 1,669
  • 18
  • 29

1 Answers1

1

Try code below:

UINavigationController *currentTopVC = (UINavigationController *)[self currentTopViewController];
BrandViewController *brandVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"BrandVC"];
[currentTopVC pushViewController:brandVC animated:YES];
kamil3
  • 1,232
  • 1
  • 14
  • 19