显示UIProgressBarHUD时禁用触摸 [英] Disabled touch when UIProgressBarHUD is shown

查看:108
本文介绍了显示UIProgressBarHUD时禁用触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个应用,其中正在创建UIProgressBarHUD以显示正在加载的内容.我的问题是,如何禁用视图,以便在加载完成之前什么也不能按下?

I've created an app where I'm creating a UIProgressBarHUD to show that something is loading. My question is, how can I disable the view so nothing can be pressed untill the loading is finished?

我尝试设置:

[self.view setUserInterationEnabled:NO];

但是这不起作用:/

这是我用来添加UIProgressHUD的代码:

Here is the code I'm using for adding the UIProgressHUD:

- (IBAction) showHUD:(id)sender
{
       //[self.view setUserInteractionEnabled:NO];

       UIProgressHUD *HUD = [[UIProgressHUD alloc]
initWithWindow:[[UIApplication sharedApplication] keyWindow]];
       [HUD setText:@"Loading…"];
       [HUD show:YES];

       [HUD performSelector:@selector(done) withObject:nil afterDelay:1.5];
       [HUD performSelector:@selector(setText:) withObject:@"Done!"
afterDelay:1.5];
       [HUD performSelector:@selector(hide) withObject:nil afterDelay:4.0];

       //[self.view setUserInteractionEnabled:YES];

       [HUD release];
}

任何帮助将不胜感激!! -詹姆斯

Any help would be muchly appreciated!! - James

推荐答案

如所指出的在这里,UIProgressHUD是私有的.您不应该使用它.

As pointed out here, UIProgressHUD is private. You should not use it.

有一个可为您提供所需的内容.

There is a library that gives you what you are looking for though.

它使您可以防止用户在按要求进行更新时点击任何内容.

It allows you to keep the user from tapping anything while it is updating as you requested.

这篇关于显示UIProgressBarHUD时禁用触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆