SVProgressHUD 如何延迟指定的时间

发布于 12-13 14:34 字数 732 浏览 5 评论 0原文

我正在使用第三部分 UIActivityIndi​​cator SVProgressHUD,当我的视图加载时我会初始化它。当我的应用程序中发生一些事情时,我想将 ActivityIndi​​cator 延迟大约 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中二柚2024-12-20 14:34:28

您可以使用计时器来设置关闭视图的方法,如下所示:

[NSTimer scheduledTimerWithTimeInterval:1 target:self
selector:@selector(myMethod) userInfo:nil repeats:NO];

使用方法:

-(void)myMethod:(NSTimer*)timer {
     // Dismiss your view
     [progressthingy dismiss];  
}

You could use a timer to set of a method that dismisses your view like so:

[NSTimer scheduledTimerWithTimeInterval:1 target:self
selector:@selector(myMethod) userInfo:nil repeats:NO];

With method:

-(void)myMethod:(NSTimer*)timer {
     // Dismiss your view
     [progressthingy dismiss];  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文