我使用MBProgressHUD向用户显示提示,但它没有显示。有许多viewcontrollers使用相同的方法。只有一个页面不能显示它,这个视图控制器是用xib创建的。该方法如下:
-(void)creatHUD:(NSString *)hud {
if (!HUD) {
HUD = [[MBProgressHUD alloc] initWithView:self.view] ;
[self.view addSubview:HUD];
HUD.delegate = self;
}
HUD.labelText = hud;
}发布于 2016-03-15 07:14:20
试试这段代码
UIView *window = [UIApplication sharedApplication].keyWindow;
MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
[hud show:YES];希望这能成功..。
发布于 2016-03-15 06:32:11
既然问题还不清楚,我想你是想用背景线索来显示。请尝尝这个。
dispatch_async(dispatch_get_main_queue(), ^{
//show Hud code here
});发布于 2016-03-15 06:36:04
我也使用MBProgressHUD,我的实现是:
[UIApplication sharedApplication].keyWindow#define APP [UIApplication sharedApplication]
+ (MBProgressHUD *)Hud
{
MBProgressHUD *hud = [MBProgressHUD HUDForView:APP.keyWindow];
if (hud){
[hud removeFromSuperview];
}else{
hud = [[MBProgressHUD alloc] initWithWindow:APP.keyWindow];
hud.removeFromSuperViewOnHide = YES;
}
[APP.keyWindow addSubview:hud];
return hud;
}
+ (void)showMsg:(NSString *)message
{
MBProgressHUD *hud = [self Hud];
hud.labelText = message;
hud.mode = MBProgressHUDModeText;
hud.labelFont = [UIFont systemFontOfSize:13];
[hud show:YES];
[hud hide:YES afterDelay:1.0];
}
+ (void)showLoading
{
[self showLoading:@"please wait..."];
}
+ (void)showLoading:(NSString *)message
{
MBProgressHUD *hud = [self Hud];
hud.labelText = message;
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelFont = [UIFont systemFontOfSize:13];
[hud show:YES];
}
+ (void)hideHUD
{
MBProgressHUD *hud = [MBProgressHUD HUDForView:APP.keyWindow];
[hud hide:YES];
}https://stackoverflow.com/questions/36004016
复制相似问题