在UICollectionView的头部中添加了一个按钮,想通过点击按钮跳转到另一个控制器,但是在UICollectionView的头部中无法使用[self.navigationController pushViewController:p animated:YES]这个方法跳转,有什么好解决方法吗??求教谢谢~!
UICollectionView
[self.navigationController pushViewController:p animated:YES]
认证0级讲师
Put the following code into your project as a category.
In the view, you can jump through [self.viewController.navigationController pushViewController:p animated:YES].
//获取某个view所在的控制器 - (UIViewController *)viewController { UIViewController *viewController = nil; UIResponder *next = self.nextResponder; while (next) { if ([next isKindOfClass:[UIViewController class]]) { viewController = (UIViewController *)next; break; } next = next.nextResponder; } return viewController; }
I tested it and it can be jumped. Is your navigation valuable? Or is it another problem? Can you make the problem more specific? It would be best if you could look at the code.
Put the following code into your project as a category.
In the view, you can jump through [self.viewController.navigationController pushViewController:p animated:YES].
I tested it and it can be jumped. Is your navigation valuable? Or is it another problem? Can you make the problem more specific? It would be best if you could look at the code.