添加子视图后self.navigationController为nil [英] self.navigationController is nil after adding subview
问题描述
这是我的产品控制器.h
here is my productscontroller.h
ProductListViewController *productListViewController;
ProductGridViewController *productGridViewController;
UIButton *flipIndicatorButton;
并且我在实现中将list和gridview作为子视图添加
and i am adding list and gridview as a subview like this in my implementation
ProductListViewController *listController = [[ProductListViewController alloc] initWithNibName:@"ProductListView" bundle:nil];
self.productListViewController = listController;
self.productListViewController.CurrentSale = CurrentSale;
[self.view insertSubview:listController.view atIndex:0];
但是当我试图像这样从ProductListViewController.m推送detailview控制器时
but in when i tried to push detailview controller from ProductListViewController.m like this
ProductDetailViewController *productDetailViewController = [[ProductDetailViewController alloc] init];
productDetailViewController.productIndexPath = indexPath;
[self.navigationController pushViewController:productDetailViewController animated:YES];
它只是不起作用,然后我检查了[self.navigationController],它为nil, 现在该如何处理这个问题.我准备提供一些代码和细节以使其更加清晰.谢谢
it just does not work, then i check [self.navigationController] , it was nil, now how to deal with this problem. i am ready to give some more code and detail to make more clear. thanks
推荐答案
我找到了解决此问题的方法. 现在我正在做的是在这种情况下我通过父控制器的ref产品控制器和书面方法来推送下一个视图.在此之后,我正在调用父方法来推这样的下一个视图 [parent pushNextview]; 到目前为止,一切正常,希望这是完成我想要的工作的好方法.
i found workaround for this problem. now what i am doing is i am passing ref of parent controller in this case ProductsController and written method to push next view. following this now i am calling parent method to push next view like this [parent pushNextview]; so far it works fine, hope this is good way of doing what i wanted to.
这篇关于添加子视图后self.navigationController为nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!