来回,removeFromSuperView
我有点困惑......
我有一个主视图,通过单击按钮显示一个子视图。接下来我想做的是 能够在主视图和子视图之间来回切换,但是当我这样做时,来自子视图的返回按钮使“到子视图”按钮被禁用......我似乎无法再次访问子视图。什么也没发生。
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这只是一个猜测,因为您没有提供太多代码:
- 您可能首先需要保留视图。如果它只被当前的超级视图保留
[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];
你为什么不试试这个呢?
打开您的子视图:
返回:
Why dont you try out this?
to open ur subview:
to go back:
为什么不直接隐藏它而不是删除它呢?
Why not just hide it instead of removing it?