开发者

How to tell when a subView is removed a UIView

开发者 https://www.devze.com 2023-03-15 03:52 出处:网络
Basically i wanted to implement a popup UIView so i followed what was posted here POP-UP UIView "IMDB App" style

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!


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.


What you could do is subclass UIView and override removeFromSuperview to send a notification. I don't think there's ever a case where a view gets removed without using the removeFromSuperview method.

0

精彩评论

暂无评论...
验证码 换一张
取 消