SVProgressHUD 如何延迟指定的时间
我正在使用第三部分 UIActivityIndicator SVProgressHUD,当我的视图加载时我会初始化它。当我的应用程序中发生一些事情时,我想将 ActivityIndicator 延迟大约 1 秒。然后调用[SVProgressHUDdismiss];基于 1 秒的等待..但我不知道该怎么做。
目前,这就是我的代码在 viewdidload 中的样子
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];
[SVProgressHUD setStatus:@"loading..."];
[SVProgressHUD dismiss];
我知道有一个 dismisswithsucsess:timer ..但这似乎延迟了我不想要的成功消息出现的时间..我想延迟指示器并有没有文字..但只是想不出办法。
我也尝试过,
sleep(1); //which dosnt work
我也尝试过
//[SVProgressHUD performSelector:@selector(stopAnimating) withObject:nil afterDelay:0];
并放置 [SVProgressHUD 解雇];在 stopAnimating 方法内,但这会失败,因为似乎所有调用都需要在同一方法内。
I am using 3rd part UIActivityIndicator SVProgressHUD, I am initalising this when my view loads. I would like to delay the activityIndicator for about 1 second while a few things in my app happen. then call [SVProgressHUD dismiss]; based off that 1 second wait.. but am not sure how to do this.
currently this is how my code looks in viewdidload
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];
[SVProgressHUD setStatus:@"loading..."];
[SVProgressHUD dismiss];
I know that there is a dismisswithsucsess:timer .. but this seems to delay the amount of time the sucsess message appears for which I don't want.. I want to delay the indicator and have no text.. but just cannot think of a way to do it.
I have tried
sleep(1); //which dosnt work
also I have tried
//[SVProgressHUD performSelector:@selector(stopAnimating) withObject:nil afterDelay:0];
and put [SVProgressHUD dismiss]; inside stopAnimating method but this falls over as it seems all of the calls need to be inside the same method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您可以使用计时器来设置关闭视图的方法,如下所示:
使用方法:
You could use a timer to set of a method that dismisses your view like so:
With method: