Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

循环引用和手动收起popView #14

Open
dagundejuzi opened this issue Mar 15, 2021 · 1 comment
Open

循环引用和手动收起popView #14

dagundejuzi opened this issue Mar 15, 2021 · 1 comment

Comments

@dagundejuzi
Copy link

在框架中,inView(父界面)被强引用,而popView又加在inView上的,这可能导致循环引用问题。

手动收起是指,如果在某界面收到需要收起popView的事件,该界面又无法直接获取到popView,这时收起popView的功能就很复杂了。比如在子模块将popView弹到window上,首页收到了推送通知将跳转至另一模块,在首页只能遍历window上的子view,判断是否是popView,然后再调用tf_hide。多个子模块都可能弹不同的自定义弹框,这时首页就要写很多 if 来判断是不是要找的popView。
这个问题,最好是能直接调个框架类方法能一次性收起所有弹框,但是想了想似乎不好实现。看了下MBProgressHUD(旧版)的收起逻辑,它是指定收起哪个界面上的hud,而且它的hud都是MBProgressHUD类型,可以很好的判断。TFPopup并没有自定义遮罩View,遮罩和popView是平级的加在inView上,TFPopup无法判断inView上是否有弹框,也无法找到弹框,所以目前的实现方式好像是做不到统一收起弹框了。

@shmxybfq
Copy link
Owner

感谢提出的bug和问题,目前bug已修复,上面的需求也增加了相应的功能。
现在添加了查找弹窗,和获取所有已弹出弹窗的功能,是view 的分类方法。
具体用法就是给弹窗view 设置一个identifier,然后可以就可以通过identifier查找。
参考下面两个方法即可:
//通过id查找弹窗,如果多个弹窗id一样,则返回最先弹出的弹窗
+(UIView *)tf_findPopup:(NSString *)identifier;
//获取所有已弹出的弹窗
+(NSArray <UIView >)tf_getAllPopup;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants