Iphone 如何使用两条后续MBProgressHUD消息
我希望在通过NSURL字符串上传期间使用MBProgressHUD显示消息。因此,我将其编码为:Iphone 如何使用两条后续MBProgressHUD消息,iphone,mbprogresshud,Iphone,Mbprogresshud,我希望在通过NSURL字符串上传期间使用MBProgressHUD显示消息。因此,我将其编码为: MBProgressHUD *hud1 = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; hud1.labelText = @"sending info ..."; hud1.minShowTime =10.0; NSURL *url =[NSURL URLWithString:self.urlToUpload]; 10秒的时间
MBProgressHUD *hud1 = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud1.labelText = @"sending info ...";
hud1.minShowTime =10.0;
NSURL *url =[NSURL URLWithString:self.urlToUpload];
10秒的时间是为了等待一些时间,我希望用户等待。它是有效的,但当第一次出现时,我会显示另一条消息。使用另一个:
MBProgressHUD *hud2 = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud2.labelText = @"SENT!";
hud2.minShowTime =2.0;
它没有用处,因为此消息与第一条消息重叠。
有什么提示吗?我会删除
-connectiondFinishLoading
方法中的第一个HUD,或者在任何您收到字符串已成功上载通知的地方
[MBProgressHUD hideHUDForView:self.view animated:YES];
然后,您可以添加下一个HUD,持续1-2秒。通过特定时间添加,无法在下一个HUD显示之前准确移除第一个HUD
这是取自演示项目。我会用这个来显示你的定时完成HUD
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
// The sample image is based on the work by http://www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/
// Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators)
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease];
// Set custom view mode
HUD.mode = MBProgressHUDModeCustomView;
HUD.delegate = self;
HUD.labelText = @"Completed";
[HUD show:YES];
[HUD hide:YES afterDelay:3];
我们还可以将MBProgressHUD提供的成功消息设置为“完成”。
+(void)toast:(NSString*) str view:(UIView*)view delegate:(id)delegate type:(IconType)type{
[MBProgressHUD hideHUDForView:view animated:YES];
MBProgressHUD * HUD = [[MBProgressHUD alloc] initWithView:view];
[view addSubview:HUD];
NSString* strImage;
switch (type) {
case kNone:
strImage=nil;
break;
case kOK:
strImage=@"37x-Checkmark.png";//NSString stringWithFormat:@"%@",
break;
case kError:
strImage=@"ic_cancel_white_24dp.png";//NSString stringWithFormat:@"%@",
break;
default:
break;
}
HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:strImage] ];
// Set custom view mode
HUD.mode = MBProgressHUDModeCustomView;
HUD.delegate = delegate;
HUD.labelText = str;
HUD.userInteractionEnabled = NO;
[HUD show:YES];
[HUD hide:YES afterDelay:1.5f];
}