我尝试使用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
答案 0 :(得分:1)
尝试以下代码:
UINavigationController *currentTopVC = (UINavigationController *)[self currentTopViewController];
BrandViewController *brandVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"BrandVC"];
[currentTopVC pushViewController:brandVC animated:YES];