来回,removeFromSuperView

发布于 2024-11-10 07:48:22 字数 374 浏览 0 评论 0原文

我有点困惑......

我有一个主视图,通过单击按钮显示一个子视图。接下来我想做的是 能够在主视图和子视图之间来回切换,但是当我这样做时,来自子视图的返回按钮使“到子视图”按钮被禁用......我似乎无法再次访问子视图。什么也没发生。

我有一个 UIButton 和一个 IBAction,我在其中写入了“[self.view removeFromSuperView];”。

请这样做不要误会我的意思,我确实回到了主视图。问题是我之后无法返回到子视图。

我已经在文档中阅读了有关保留子视图的内容...但我不太明白如何做到这一点。

有人可以解释一下吗?

谢谢!

Im a bit confused...

I have a mainview, which by the click of a button shows a subview. What I want to do next is to
be able to switch back and forth between the Main and the Sub, but when I do this, the return button FROM the subView makes the TO SubView button disabled...I cant seem to be able to access the Subview a second time. Nothing happens.

What I have is a UIButton, and an IBAction, which I have written the "[self.view removeFromSuperView];" in.

Please do not get me wrong here, I do get back to the mainView. The problem is that I cant go back to the subview afterwards.

I've read something in the documentation about retaining the subView...But I did not quite understand how to do it.

Could anyone please shed some light over this?

Thanks!

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

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

发布评论

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

评论(3

那伤。 2024-11-17 07:48:22

这只是一个猜测,因为您没有提供太多代码:
- 您可能首先需要保留视图。如果它只被当前的超级视图保留
[self.viewretain];

记住当不再需要它时手动释放它。
[self.view 发布];

this is just a guess, since you don't provide much code:
- you might first need to retain the view. in case it's only retained by its current superview
[self.view retain];

remember to free it manually when it's no longer needed.
[self.view release];

梦毁影碎の 2024-11-17 07:48:22

你为什么不试试这个呢?

打开您的子视图:

Ursubview *Ursubview    =[[Ursubview alloc] initWithNibName:nil bundle:nil];
Ursubview.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:Ursubview animated:YES];

返回:

[self dismissModalViewControllerAnimated:YES];

Why dont you try out this?

to open ur subview:

Ursubview *Ursubview    =[[Ursubview alloc] initWithNibName:nil bundle:nil];
Ursubview.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:Ursubview animated:YES];

to go back:

[self dismissModalViewControllerAnimated:YES];
一页 2024-11-17 07:48:22

为什么不直接隐藏它而不是删除它呢?

Why not just hide it instead of removing it?

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