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

There are still cases where the HUD is not displayed. #1121

Open
hubin97 opened this issue Jan 29, 2024 · 1 comment
Open

There are still cases where the HUD is not displayed. #1121

hubin97 opened this issue Jan 29, 2024 · 1 comment

Comments

@hubin97
Copy link

hubin97 commented Jan 29, 2024

Similar to #812

This situation still exists when using pod 'SVProgressHUD', '~> 2.3.1'. It cannot be said to be a problem, but it can only be said to be related to the mechanism;
The SVProgressHUD.setContainerView method globally modifies the displayed container. This is how I handle it. After the page using SVProgressHUD.setContainerView is destroyed, I call SVProgressHUD.setContainerView(nil) again.

     /// Device connection animation
     static func cnctAnimate(content: String = "Connecting".localized, forView: UIView? = nil) {
         SVProgressHUD.setMinimumSize(CGSize(width: 200, height: 100))
         SVProgressHUD.setDefaultStyle(.custom)
         SVProgressHUD.setBackgroundColor(.systemGroupedBackground)
         SVProgressHUD.setForegroundColor(.black)
         SVProgressHUD.setDefaultMaskType(.black)
         SVProgressHUD.show(withStatus: content)
         if let view = forView {
             SVProgressHUD.setContainerView(view)
             SVProgressHUD.setOffsetFromCenter(UIOffset(horizontal: -view.origin.x, vertical: -view.origin.y - kNavBarAndSafeHeight/2))
         }
     }
    
     // FIXME: There is a problem with the use of setContainerView. It must be restored after use, otherwise the prompt added to the window will not be displayed.
     static func dismissAnimate() {
         SVProgressHUD.setContainerView(nil)
         SVProgressHUD.setOffsetFromCenter(UIOffset.zero)
     }

使用pod 'SVProgressHUD', '~> 2.3.1'还是存在这个情况, 不能说是问题, 只能说和机制相关;
SVProgressHUD.setContainerView 方法是全局修改了展示的容器, 我是这么处理的, 在使用完SVProgressHUD.setContainerView的页面销毁后, 再调用 SVProgressHUD.setContainerView(nil),

    /// 设备连接动画
    static func cnctAnimate(content: String = "Connecting".localized, forView: UIView? = nil) {
        SVProgressHUD.setMinimumSize(CGSize(width: 200, height: 100))
        SVProgressHUD.setDefaultStyle(.custom)
        SVProgressHUD.setBackgroundColor(.systemGroupedBackground)
        SVProgressHUD.setForegroundColor(.black)
        SVProgressHUD.setDefaultMaskType(.black)
        SVProgressHUD.show(withStatus: content)
        if let view = forView {
            SVProgressHUD.setContainerView(view)
            SVProgressHUD.setOffsetFromCenter(UIOffset(horizontal: -view.origin.x, vertical: -view.origin.y - kNavBarAndSafeHeight/2))
        }
    }
    
    // FIXME: setContainerView使用存在问题, 使用后得还原, 否则会使加在window的提示不显示
    static func dismissAnimate() {
        SVProgressHUD.setContainerView(nil)
        SVProgressHUD.setOffsetFromCenter(UIOffset.zero)
    }
@godLoveY
Copy link

godLoveY commented Jan 29, 2024 via email

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