iOS - 在presentViewController之后,除了navigationBar之外没有任何可点击的内容

时间:2017-04-27 11:28:40

标签: ios objective-c navigation

我尝试使用BrandViewController方法从视图(MainCollectionViewCell.m)中呈现viewController(didselectItemAt)。所以,

- (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;
}

此代码正确显示BrandViewController,但除了我的后退按钮外,我无法点击BrandViewController中的任何按钮或图片。你能否就这个问题给我任何想法?

编辑:我有两个collectionViews。一个在MainViewController(MainCollectionView)中,另一个在MainCollectionViewCell(从此处调用didSelectItemAt方法)内。

edited2:呈现的View层次结构有两个UITransitionView

enter image description here

1 个答案:

答案 0 :(得分:1)

尝试以下代码:

UINavigationController *currentTopVC = (UINavigationController *)[self currentTopViewController];
BrandViewController *brandVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"BrandVC"];
[currentTopVC pushViewController:brandVC animated:YES];