为什么方法中 self.navigationController = nil

发布于 2024-09-27 18:13:13 字数 866 浏览 7 评论 0原文

由于某种未知的原因,我无法推动观点,我会尽力解释,但我有很多复杂的观点,解释起来将是一场噩梦,但说我有以下方法。

 -(void)showDetailView{ 
DetailViewController *detailView = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
 [self.navigationController pushViewController:detailView animated:YES];
 [detailView release]; 
  }

它可以工作并将详细视图推送到堆栈上,这是在我的主视图和主线程上。

因此,在表视图中,我有一个带有子视图的单元格,然后该单元格从另一个视图控制器获取其视图。在该视图控制器中,我有更多子视图,并且当用户单击子视图时调用一个方法。这又会在 mainView 上调用这个方法。

因此人们会认为应该提出一种新的观点。代码运行,没有错误发生,但视图没有更改/切换。

我尝试了各种方法将视图推送到调用它的视图控制器内。然后只需调用一个直接连接到导航控制器的方法来推送视图。

有几件事需要补充。 1.我有一个 IBAaction 按钮,可以推送视图(效果很好) 2.我认为这是因为我经历了很多视图,但我假设如果你调用推送视图控制器,它会推送你传递给它的任何视图。 3.我检查了从主视图调用该方法时 self.navigationcontroller 不= null。

但如果通过方法 call it = null 来调用导航控制器。

那么有没有办法恢复导航控制器的空值呢?

我有点困惑为什么我不能简单地调用一个方法来推送视图

谢谢

For some unknown reason I cannot push a view, I will try to explain the best I can but i have alot of complicated views going on, And it would be a nightmare to explain but say I have the following method.

 -(void)showDetailView{ 
DetailViewController *detailView = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
 [self.navigationController pushViewController:detailView animated:YES];
 [detailView release]; 
  }

Which works and would push the detail view onto the stack, this is on my main view and my main thread.

So in the table view i have a cell with a Subview that then takes its view from another view controller. In that view controller I have more subviews, and say when a user clicks a subview a method is called. Which in turn will call this method on the mainView.

So one would believe that then a new view should get pushed. And the code runs, no errors occur but the view is not changed/switched.

I have tried various method of pushing a view inside the view controller that is it called from. and then just calling a method which is directly connected to the navigation controller to push the views.

A few things to add.
1. I have a IBAaction button that pushes a view (that works fine)
2. I assume its because im through so many views but I'm assuming that if you call push view controller it will push whatever view you pass it.
3. I have checked when the method is called from the main view self.navigationcontroller does not = null.

But if the navigation controller is called through the method call it = null.

So is there anyway to restore the null value of a navigation controller?

Im a little confused on why i cant simply call a method to push a view

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缺⑴份安定 2024-10-04 18:13:13

好的,我现在已经对它进行了排序

就我如何解决访问我的视图的上级超级视图而言,是

视图超级视图的 ID 标记,这是我的子视图所在的单元格

id CellController = [self.view.superview.superview nextResponder];
[CellController performSelector:@selector(showDetailView:) withObject:Link];

然后调用我的单元格中的一个方法,然后依次访问它的superview

id mainController = [self.view.superview.superview nextResponder];
[mainController performSelector:@selector(showDetailView:) withObject:Link];

然后主视图仍然保留其导航控制器,然后在主视图的显示详细信息方法中传递链接并推送新视图。

基本上,子视图的总超级视图不能高于它创建的位置。因此,我的单元格中的子视图永远无法通过我的主视图正确访问和运行任何内容,我可以填充但它从未执行应有的操作。因此,访问其最高级别的超级视图,然后使其访问其超级视图,因为单元格位于我的主视图中,然后我可以正确运行方法。

希望只有我认真思考这一切才有意义。

感谢-> 如何访问超级的视图控制器?

对于 ID标签位,没有以这种方式使用 Id,所以学到了另一件事

Its ok I have sorted it now

In terms of how i solved accessing the superior superview to my view is

An ID tag to the views superview which is the cell that my subview is in

id CellController = [self.view.superview.superview nextResponder];
[CellController performSelector:@selector(showDetailView:) withObject:Link];

Then calling a method in my cell which then in turn access its superview

id mainController = [self.view.superview.superview nextResponder];
[mainController performSelector:@selector(showDetailView:) withObject:Link];

Which then the main still retains its navigation controller and then in the show detail method in the main passes the link and pushes the new view.

Basically the total superview of a subview can be no higher then wherever it was created. So the subview in my cell could never access and run anything through my mainView properly, i could stuff but it never performed how it should be. So accessing its highest level superview and then getting that to access its superview as the cell is in my main view then I could run methods correctly.

Hope this makes sense only getting my head around it all.

Thanks to -> How does one access a super's view controller?

For the Id tag bit, not used Id in this way so another things learnt

铜锣湾横着走 2024-10-04 18:13:13

我今天遇到了几乎同样的问题。如果在推送视图时导航栏被隐藏,则您的导航控制器可能为零。我这样解决问题:

self.navigationController.navigationBarHidden = NO; // So the navigation controller is not nil
[self.navigationController pushViewController:articleInfoController animated:YES];

I just had nearly the same problem today. If the navigation bar is hidden when you push a view, you may have a nil navigation controller. I resolve the problem like this :

self.navigationController.navigationBarHidden = NO; // So the navigation controller is not nil
[self.navigationController pushViewController:articleInfoController animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文