我尝试使用viewController(BrandViewController
)从视图(MainCollectionViewCell.m
)表示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
,但是除了我的back按钮之外,我不能单击来自BrandViewController
的任何按钮或图像。你能给我一点关于这个问题的想法吗?
编辑:我有两个collectionViews。一个在MainViewController(MainCollectionView
)中,另一个在MainCollectionViewCell
(从这里调用的didSelectItemAt
方法)中。
edited2:呈现视图层次结构有两个UITransitionView
发布于 2017-04-27 12:10:58
尝试下面的代码:
UINavigationController *currentTopVC = (UINavigationController *)[self currentTopViewController];
BrandViewController *brandVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"BrandVC"];
[currentTopVC pushViewController:brandVC animated:YES];
https://stackoverflow.com/questions/43656500
复制相似问题