iPhone UIViews 在重新进入视图后休眠/死亡

发布于 2024-08-07 06:23:57 字数 511 浏览 3 评论 0原文

我需要一些帮助。这似乎是我在编码中添加和更改视图时遇到的常见问题。我很想知道我做错了什么。

目前,我正在使用视图控制器中的以下调用添加和删除视图:

[startView removeFromSuperview];
[self addSubview:secondView];

然后再次执行相反的操作以返回。

[secondView removeFromSuperview];
[self addSubview:startView];

到目前为止我很好。 但我遇到的问题是,当我决定返回“startView”并第二次调用上面的第一个代码时。 我的视图已加载,但效果甚微。 我的方法都没有被调用,没有动画并且显示了视图,但它是“死的”或“睡着的”。我不知道为什么!

我基本上是添加一个视图,删除它,然后再次添加它,一切都会崩溃。 谁能帮我看看可能会发生什么? ViewDidLoad 在第二次加载时不会触发吗?或者类似的东西? 我将非常感激。

I need some help. This seems to be a common problem I am having when am adding and changing views in my coding. And I would love to learn what I am doing wrong.

Currently I am adding and removing views using the following calls from my view controller:

[startView removeFromSuperview];
[self addSubview:secondView];

and then doing the opposite again to go back.

[secondView removeFromSuperview];
[self addSubview:startView];

I am fine up to this point.
But the problem I have is that when I then decide to go back to 'startView" and call the first code that I have above for the second time.
My View loads but very little works.
None of my methods are called, there is no animation and the view is shown but it is "dead" or "asleep". And I have no idea why!

I am basically adding a view, removing it, then adding it again and everything breaks.
Can anyone give me a hand as to what might be happening? is it that ViewDidLoad doesn't fire the second time it's loaded? or something like that?
I would much appreciate it.

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

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

发布评论

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

评论(1

葬﹪忆之殇 2024-08-14 06:23:57

我可能已经弄清楚了所以别担心!

我的代码中隐藏了一个标志,阻止我的方法触发。
对不起!

I may have figured it out So don't worry!

I had a flag hidden in my code somewhere that was stopping my methods from firing.
Sorry!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文