我正在使用 M13ProgressHUD在我的应用程序中显示加载器。它工作正常,但如果我在加载程序打开时将我的应用程序发送到后台,然后返回,加载程序将被卡住。为什么会这样?
我将 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];
});
为什么当应用程序返回前台时它会被卡住,即使我将它添加到主队列中也是如此?
最佳答案
当 iOS 应用程序进入后台时,所有图层中的所有动画都会被移除。我快速搜索了 M13ProgressSuite 源代码。该库似乎对 UIApplicationDidEnterBackgroundNotification
和 UIApplicationWillEnterForegroundNotification
通知没有反应。因此,当应用进入前台时,库不会重新建立动画。
另见 this github上的问题
您可以订阅 UIApplicationDidEnterBackgroundNotification
和 UIApplicationWillEnterForegroundNotification
通知并自行对它们使用react。
关于ios - 当应用程序从后台返回时,进度 HUD 卡住 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35010533/