ios - UICollectionView的头部无法使用pushViewController跳转,如何解决?
PHP中文网
PHP中文网 2017-04-18 09:40:17
0
2
738

UICollectionView的头部中添加了一个按钮,想通过点击按钮跳转到另一个控制器,但是在UICollectionView的头部中无法使用[self.navigationController pushViewController:p animated:YES]这个方法跳转,有什么好解决方法吗??求教谢谢~!

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
左手右手慢动作

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template