タイトルが示すように、悪名高い rederInContext クラッシュの問題が発生しています。私はオンラインで多くの投稿を読みましたが、この問題を解決する方法や私のために働いたものについては、とにかく何も与えていないようです.
すでに説明した一般的なエラーから始めましょう。私は使用@autorelease{ code }
していますが、メモリ警告の問題は発生していません。また、メインスレッドで実行しようとしましたが、どちらも機能しませんでした。ステートメントに到達したときに、ビューのどのレイヤーもヌルではありません。私はそれらを NSLogged しましたが、それらはすべて null ではありません。いくつかのコードを試してみましたが、それらに対応するエラーを投稿します。
試み#1
-(void){
@autorelease{
//UIGraphicsBeginImageContext(self.mapView.bounds);
UIGraphicsBeginImageContextWithOptions(self.mapView.bounds, NO, 0.0);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(c, 0, 0);
[self.mapView.layer renderInContext:c]; //Crashes HERE :(
UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
viewImage = [viewImage applyBlurWithRadius:4.0f tintColor:[UIColor colorWithWhite:0.2 alpha:0.55] saturationDeltaFactor:1.0 maskImage:nil];
UIGraphicsEndImageContext();
UIImageView *newView = [[UIImageView alloc] initWithFrame:self.mapView.frame];
newView.backgroundColor = [UIColor clearColor];
newView.image = viewImage;
newView.tag = 10;
newView.alpha = 0.1;
[self.mapView addSubview:newView];
self.mapView.userInteractionEnabled = NO;
[UIView animateWithDuration:0.15 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{ newView.alpha = 1.0;} completion:^(BOOL finished){}];
}
}
// ** ERROR MESSAGES **
<Error>: CGImageCreate: invalid image width.
<Error>: CGContextSaveGState: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextClipToRect: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSaveGState: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSaveGState: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSetFillColorWithColor: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextAddRect: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextDrawPath: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextRestoreGState: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSaveGState: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextGetBaseCTM: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextConcatCTM: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSetBaseCTM: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSaveGState: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSaveGState: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextClipToRect: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextBeginTransparencyLayerWithRect: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSetFillColorSpace: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
<Error>: CGContextSetStrokeColorSpace: invalid context 0x1e432510. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
*** -[Not A Type retain]: message sent to deallocated instance 0x1e432510
試行 #2 - mainThread での呼び出し
-(void)blurrEffect{
[self performSelectorOnMainThread:@selector(captureBlur) withObject:nil waitUntilDone:YES];
}
-(void)captureBlur
{
@autorelease{
//UIGraphicsBeginImageContext(self.mapView.bounds);
UIGraphicsBeginImageContextWithOptions(self.mapView.bounds, NO, 0.0);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(c, 0, 0);
[self.mapView.layer renderInContext:c]; //Crashes HERE :(
UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
viewImage = [viewImage applyBlurWithRadius:4.0f tintColor:[UIColor colorWithWhite:0.2 alpha:0.55] saturationDeltaFactor:1.0 maskImage:nil];
UIGraphicsEndImageContext();
UIImageView *newView = [[UIImageView alloc] initWithFrame:self.mapView.frame];
newView.backgroundColor = [UIColor clearColor];
newView.image = viewImage;
newView.tag = 10;
newView.alpha = 0.1;
[self.mapView addSubview:newView];
self.mapView.userInteractionEnabled = NO;
[UIView animateWithDuration:0.15 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{ newView.alpha = 1.0;} completion:^(BOOL finished){}];
}
}
// **ERROR MESSAGE**
malloc: *** mmap(size=1923772416) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
試み #3
-(void)blurEffect{
[self performSelector:@selector(captureBlur) withObject:nil afterDelay:0.5];
}
-(void)captureblur{
@autorelease{
//UIGraphicsBeginImageContext(self.mapView.bounds);
UIGraphicsBeginImageContextWithOptions(self.mapView.bounds, NO, 0.0);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(c, 0, 0);
[self.mapView.layer renderInContext:c]; //Crashes HERE :(
UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
viewImage = [viewImage applyBlurWithRadius:4.0f tintColor:[UIColor colorWithWhite:0.2 alpha:0.55] saturationDeltaFactor:1.0 maskImage:nil];
UIGraphicsEndImageContext();
UIImageView *newView = [[UIImageView alloc] initWithFrame:self.mapView.frame];
newView.backgroundColor = [UIColor clearColor];
newView.image = viewImage;
newView.tag = 10;
newView.alpha = 0.1;
[self.mapView addSubview:newView];
self.mapView.userInteractionEnabled = NO;
[UIView animateWithDuration:0.15 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{ newView.alpha = 1.0;} completion:^(BOOL finished){}];
}
}
// **ERROR MESSAGE**
terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
また、stackoverflow に投稿されている FXBlurView を使用してその自動解放コードを切り替えてみました。そのコードベースも renderInContext を使用しており、同じ場所でクラッシュします。
これが壊れている理由と修正方法について、アイデアや解決策はありますか? ガイダンスや情報が役立ちます!前もって感謝します!
PS: iOS7 のみをサポートしている場合は、UIToolbar を使用できますが、そのぼかし効果は、私が使用しているものではひどく見え、iOS6 もサポートしているため、問題外です。
編集: UIGraphicsBeginImageContextWithOptions(self.mapView.bounds.size, NO, 0.0);
CGContextTranslateCTMなしでコードを追加し、実行しようとしました。それでも墜落した。