如何判断子视图何时被移除 UIView
基本上我想实现一个弹出 UIView 所以我遵循了这里发布的内容 POP-UP UIView“IMDB App”样式
这非常有效。不过我有一个疑问。我的主要视图是 tableView。因此,当弹出视图时,我禁用表格中的滚动。现在,当弹出子视图被删除时,我需要重新启用滚动。我怎样才能做到这一点?我无法使用 willRemoveFromSuperview 因为弹出视图完全加载不同的 NIB。
我应该使用通知吗?
希望我能清楚地解释这个场景。
提前致谢!
Basically i wanted to implement a popup UIView so i followed what was posted here
POP-UP UIView "IMDB App" style
This works very well. However i have one query. My main view is a tableView. so when a view is popped up i disable scrolling in the table. Now when the popup subView is removed, i need to re-enable scrolling. How do i achieve that? i can't use willRemoveFromSuperview because the popup view is loading a different NIB altogether.
Should i use Notifications?
hope i was clear with explaining the scenario.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
重罪猫有正确答案。这是在弹出视图中使用
@protocol
以及注册委托的完美方式。有东西触发该弹出视图关闭。无论触发器是什么,调用协议,委托就可以根据需要处理情况。此外,当正确使用协议时,您的代码在一个项目以及其他项目中变得非常可重用。
Feloneous Cat has the correct answer. This is the perfect use a
@protocol
in your popup view along with a registered delegate. Something is triggering that popup view to close. Whatever that trigger is, call the protocol and the delegate can handle the situation as needed.Furthermore, when protocols are used correctly, your code becomes very reusable within a project as well as in other projects.
您可以做的是子类
UIView
并重写removeFromSuperview
来发送通知。我不认为存在不使用removeFromSuperview
方法就删除视图的情况。What you could do is subclass
UIView
and overrideremoveFromSuperview
to send a notification. I don't think there's ever a case where a view gets removed without using theremoveFromSuperview
method.