应用程序从后台返回时,进度HUD卡住了 - iOS

3
我正在使用M13ProgressHUD在我的应用程序中显示一个加载器。它的功能很好,但是如果我在加载器打开的时候将我的应用程序切换到后台,再返回前台,加载器会被冻结。为什么会发生这种情况?

image

我添加hud的方式是:
_hud = [[M13ProgressHUD alloc] initWithProgressView:[[M13ProgressViewRing alloc] init]];
_hud.progressViewSize = CGSizeMake(60.0, 60.0);
_hud.animationPoint = CGPointMake([UIScreen mainScreen].bounds.size.width / 2, [UIScreen mainScreen].bounds.size.height / 2);
_hud.indeterminate = YES;
_hud.primaryColor = [UIColor whisperRed];
_hud.secondaryColor = [UIColor whisperRed];
((M13ProgressViewRing*)_hud.progressView).backgroundRingWidth = 2.0;
_hud.maskType = M13ProgressHUDMaskTypeSolidColor;
UIWindow *window = ((AppDelegate *)[UIApplication sharedApplication].delegate).window;
[window addSubview:_hud];

并将其显示为:

dispatch_async(dispatch_get_main_queue(), ^{
        // Show an activity indicator
        [_hud performAction:M13ProgressViewActionNone animated:YES];
        [_hud setStatus:@"Connecting via Facebook"];
        [_hud setIndeterminate:YES];
        [_hud show:YES];
    });

为什么当应用程序回到前台时会出现卡顿,即使我已将其添加到主队列中?

2个回答

1
当iOS应用程序进入后台时,所有图层的动画都将被移除。我快速搜索了M13ProgressSuite源代码。看起来该库不会对UIApplicationDidEnterBackgroundNotificationUIApplicationWillEnterForegroundNotification通知做出反应。因此,当应用程序回到前台时,该库不会重新建立动画。
另请参见github上的this问题
您可以订阅UIApplicationDidEnterBackgroundNotificationUIApplicationWillEnterForegroundNotification通知,并自己对其进行反应。

0
self.view中添加hud视图,我查看了库并发现库中存在问题,也在github上报告了。我在大多数项目中使用MBPrgressHud,它对我很有效。另一个解决方法是使用UIApplicationWillEnterForegroundNotification并在那里重新启动动画。

问题链接的详细信息


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接