gpt4 book ai didi

iphone - 如何使用两个后续的 MBProgressHUD 消息

转载 作者:行者123 更新时间:2023-12-03 20:27:52 25 4
gpt4 key购买 nike

我想在通过 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 *hud2 = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 
hud2.labelText = @"SENT!";
hud2.minShowTime =2.0;

它没有用,因为此消息与第一个消息重叠。有什么建议吗?

最佳答案

我会删除您的 -connectionDidFinishLoading 方法中的第一个 HUD,或者您收到字符串已成功上传通知的任何位置。

[MBProgressHUD hideHUDForView:self.view animated:YES];

然后您可以在 1-2 秒内添加下一个 HUD。仅通过特定时间添加它,无法在下一个 HUD 显示之前准确删除第一个 HUD。

这取自MBProgressHUD演示项目。我将用它来显示您的定时完成 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];

关于iphone - 如何使用两个后续的 MBProgressHUD 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11891080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com