ios - MBProgressHUD 宽限时间和最小时间无法正常工作。如何实现。?
<p><p>我正在使用 <a href="https://github.com/matej/MBProgressHUD/" rel="noreferrer noopener nofollow">MBProgressHUD</a>用于在执行本地长方法时显示加载,以提供用户良好的体验。一切正常,但现在我必须像这样实现,如果该方法在一秒钟内执行,则不应出现加载。我浏览了 MBProgressHUD 示例,对于这个功能,我发现 <code>setGraceTime</code> 和 <code>setMinShowTime</code> 显示时间,但它们都不能正常工作。因为当我设置宽限时间时,即使方法执行时间超过 1 秒,加载图标也不会出现。这是我的代码</p>
<pre><code> if (self.HUD == nil)
{
self.HUD = [ initWithView:self.view];
;
}
self.HUD.labelText = @"Please wait.....";
// ;
;
;
;
// ;
[ runUntilDate:];
if (mycondition == nil)
{
];
//];
}
else
{
//else
}
self.tempView.hidden = YES;
// self.HUD.taskInProgress = NO;
;
self.HUD = nil;
</code></pre>
<p>我已经为 <a href="https://stackoverflow.com/questions/5685331/run-mbprogresshud-in-another-thread" rel="noreferrer noopener nofollow">this problem's solution </a> 添加了 <code>[ runUntilDate:];</code>
请指导我这段代码有什么问题..?!</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您需要在方法执行中从其父 View 中移除 <code>MBProgressHUD</code> 对象。
像这样:</p>
<blockquote>
<p>// if the method runs inside one second, the indicator will not be
shown</p>
</blockquote>
<pre><code>- (void)viewDidLoad
{
;
if (HUD == nil)
{
HUD = [ initWithView:self.view];
;
}
HUD.labelText = @"Please wait.....";
;
;
;
;
}
- (void)runThisMethod
{
;
}
</code></pre>
<blockquote>
<p>// if the method runs after one second, the indicator will be
shown for some time until the method runs</p>
</blockquote>
<pre><code>- (void)viewDidLoad
{
;
if (HUD == nil)
{
HUD = [ initWithView:self.view];
;
}
HUD.labelText = @"Please wait.....";
;
;
;
;
}
- (void)runThisMethod
{
;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - MBProgressHUD 宽限时间和最小时间无法正常工作。如何实现。?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/18008708/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/18008708/
</a>
</p>
页:
[1]