jdg / MBProgressHUD

MBProgressHUD + Customizations
http://www.bukovinski.com/
MIT License
16.01k stars 3.56k forks source link

Button always shows #435

Closed ShadowLJia closed 6 years ago

ShadowLJia commented 8 years ago

`self.hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:animated];

self.hud.button.hidden = YES;

self.hud.square = YES;`

is the button always shows?

wangbiye commented 7 years ago

Find out why?

wzso commented 7 years ago

Me too. Have you figured it out? This is how I do it:


    hud.mode = MBProgressHUDModeText;
    hud.detailsLabel.text = message;
    hud.detailsLabel.font = [UIFont systemFontOfSize:17.f];
    [hud showAnimated:YES];
    [hud hideAnimated:YES afterDelay:duration];
wzso commented 7 years ago

@ShadowLJia @wangbiye , hi, I think I find out the reason for this. As commented in the header file MBProgressHUD.h of property button says, the button is "Visible only if a target / action is added".

You can also find the impl of this visibility logic in -[MBProgressHUDRoundedButton intrinsicContentSize].

I added a breakpoint and executed po hud.button.allTargets on the console, it logged this: {( <GrowingUIControlObserver: 0x17021edf0> )}.

So I'm guessing maybe this is the reason for your issue too.

lvjunhang commented 7 years ago

same issue.Have you solve it ? @zssr 怎么解决的?

wzso commented 7 years ago

@stillwalk , 我用不上那个按钮,然后直接就在 -[MBProgressHUDRoundedButton intrinsicContentSize]return CGSizeZero

也可以修改HUD创建子视图里面的代码。

lvjunhang commented 7 years ago

Thankyou @zssr

MrPans commented 7 years ago

thanks, it's work for me.

wzso commented 6 years ago

hi, to those who use GrowingIO, I have a better solution. Since the button is "visible only if a target / action is added".

removeTargetsAt(button: hud.button)

private static func removeTargetsAt(button: UIButton) {
    for t in button.allTargets {
        button.removeTarget(t, action: nil, for: .allEvents)
    }
}