New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in background thread #76
Comments
Please test the following code: Replace makeBlurBackground by : - (void)makeBlurBackground
{
UIImage *image = [UIImage convertViewToImage:_rootViewController.view];
UIImage *blurSnapshotImage = [image applyBlurWithRadius:5.0f
tintColor:[UIColor colorWithWhite:0.2f
alpha:0.7f]
saturationDeltaFactor:1.8f
maskImage:nil];
_backgroundView.image = blurSnapshotImage;
_backgroundView.alpha = 0.0f;
_backgroundOpacity = 1.0f;
} Replace convertViewToImage by : #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
+ (UIImage*)convertViewToImage:(UIView *)view
{
CGFloat scale = [UIScreen mainScreen].scale;
UIImage *capturedScreen;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
{
//Optimized/fast method for rendering a UIView as image on iOS 7 and later versions.
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, scale);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
else
{
//For devices running on earlier iOS versions.
UIGraphicsBeginImageContextWithOptions(view.bounds.size,YES, scale);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
capturedScreen = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
return capturedScreen;
} |
Hi, thank you for the very quick response! I replaced both of those methods and the alert now displays. Thank you very much! :) |
dogo
added a commit
that referenced
this issue
Mar 10, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to display an SCLAlertView in my app, but I am getting this error:
on this line
[keyWindow.layer renderInContext:context];
I am creating the alert after I call one of my parse cloud code functions. I have read that renderInContext should not be called in a background thread, but I have this exact same code in a different view controller (also after I call a cloud code function), and the alert displays perfectly.
Also, if I display and hide a regular UIAlertView immediately before I show this one, the SCLAlertView shows without a problem, but the view behind it is a solid white. Why is this happening? Is UIAlertView somehow breaking out of the background thread?
I have tried displaying the SCLAlertView in a background thread as suggested here: http://stackoverflow.com/questions/15135208/objective-c-renderincontext-crash-on-background-thread but the app still crashed.
Here is my code to display the alert:
The text was updated successfully, but these errors were encountered: