Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS-显示视图控制器后,除导航栏外,无法单击任何内容_Ios_Objective C_Navigation - Fatal编程技术网

iOS-显示视图控制器后,除导航栏外,无法单击任何内容

iOS-显示视图控制器后,除导航栏外,无法单击任何内容,ios,objective-c,navigation,Ios,Objective C,Navigation,我尝试使用didselectItemAt方法从视图(MainCollectionViewCell.m)显示viewController(BrandViewController)。所以 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { UIViewController *currentTopVC = [self c

我尝试使用
didselectItemAt
方法从视图(
MainCollectionViewCell.m
)显示viewController(
BrandViewController
)。所以

- (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
中的任何按钮或图像。你能给我一些关于这个问题的想法吗


编辑:我有两个CollectionView。一个位于MainViewController(
MainCollectionView
)中,另一个位于
MainCollectionViewCell
中(
didSelectItemAt
方法在此调用)

edited2:显示的视图层次结构有两个
UITransitionView

请尝试下面的代码:

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

请确保您的brandVC.view.userInteractionEnable=true。@jigneshVadadoriya谢谢,我试过了,但仍然不起作用。。为什么必须找到top view控制器?你能不能只用
self
?@Tj3n我试着从
视图
而不是从
控制器
调用该方法。因此,我无法通过
self
捕捉
controller
(self是我的collectionViewCell)。明白了,试着打印出你得到的
currentTopVC
,如果不是你的
MainCollectionView
类,那就是问题所在,否则试着用一个带按钮的空白控制器替换你的
BrandViewController
,看看你能不能告诉我你是我的救命恩人,省时恩人@哦,也谢谢你。你能解释一下问题是什么吗?那我也可以投你的票!您只能在任何Viewcontroller和导航堆栈上显示Viewcontroller