Don't allow user interaction when activity indicator view is visible

后端 未结 10 2192
你的背包
你的背包 2020-12-24 02:30

I have a view which contains two views. One of those views contains two buttons and some text labels. The other one, with alpha set to 0.25, has an UIActivityIndicator

10条回答
  •  渐次进展
    2020-12-24 03:13

    You could disable/enable the UIButtons based on the UIActivityIndicatorView being shown or not. Or, if you just want to "discard the user interaction" while the spinner is shown, in the button handler method:

    - (void)buttonTapped:(id)sender {
        if ([spinner superview] != nil && [spinner isAnimating]) {
            return;
        }
        // ... the rest of your code
    }
    

    This example assumes that when you hide the UIActivityIndicatorView you call one of:

    [spinner removeFromSuperview];
    

    or

    [spinner stopAnimating];
    

提交回复
热议问题