UINavigationController - 流行
我在从导航堆栈中弹出项目时遇到一些问题,并且不知道为什么它会这样。
Stack
A classA
B classB
C classC
D classD
在堆栈 DI 中创建另一个 classD 并将其添加到堆栈中。
Stack
A classA
B classB
C classC
D classD
E classD
在创建 E 并将其推入堆栈之前,我执行了一次弹出操作以摆脱 D,以便堆栈变为
Stack
A classA
B classB
C classC
E classD
但是当我弹出时, self.navigationController.viewcontrollers 变为 0 并且我卡在 C 上,而 E 不可见。为什么 pop 会删除所有内容并转到 C?
在 didSelectRowAtIndexPath 中的 C 处,我创建了一个 ClassD 并执行以下操作:
[self.navigationController pushViewController:ClassD animated:YES];
在 didSelectRowAtIndexPath 中的 D 处,我创建了另一个 ClassD 并执行以下操作:
[self.navigationController popViewControllerAnimated:NO]; //remove current and replace with new
[self.navigationController pushViewController:ClassD animated:YES];
但它似乎没有按预期执行操作。我感觉从流行到推送的转变似乎太快了,什么也没有出现?有什么想法吗?
I am having some problems with popping items from the navigation stack and no idea why its behaving like it is.
Stack
A classA
B classB
C classC
D classD
At stack D I create another classD and add it to the stack.
Stack
A classA
B classB
C classC
D classD
E classD
Before I create E and push it on to the stack, I do a pop to get rid of D so that the stack becomes
Stack
A classA
B classB
C classC
E classD
However when I pop, the self.navigationController.viewcontrollers becomes 0 and im stuck on C with E not becoming visible. Why does the pop just remove everything and go to C?
At C in didSelectRowAtIndexPath I create a ClassD and do:
[self.navigationController pushViewController:ClassD animated:YES];
At D in didSelectRowAtIndexPath I create another ClassD and do:
[self.navigationController popViewControllerAnimated:NO]; //remove current and replace with new
[self.navigationController pushViewController:ClassD animated:YES];
But it doesn't seem to do what as expected. I sense the transition from pop to push seems to be too fast nothing is appearing? Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来
popViewController
也将self.navigationController
设置为nil
。如果 self.navigationController 为 nil,则 [self.navigationController anyMethod] 不执行任何操作。试试这个(未测试):
如果这个 导致 self 被破坏的问题 然后只需在 pop 之前添加以下行:
it sounds like the
popViewController
is also setting theself.navigationController
tonil
. ifself.navigationController
isnil
then[self.navigationController anyMethod]
does nothing.try this (not tested):
if this causes the problem that self is beeing destroyed then just add the following line before pop: