我正在尝试在我的应用中显示SCLAlertView,但我收到此错误:
Thread 1: EXC_BAD_ACCESS (code=EXC_1386_GPFLT)
在此行[keyWindow.layer renderInContext:context];
在我调用我的一个解析云代码函数后,我正在创建警报。我已经读过不应该在后台线程中调用renderInContext,但是我在不同的视图控制器中也有相同的代码(在我调用云代码函数之后),并且警报显示完美。
另外,如果我在显示之前立即显示和隐藏常规UIAlertView,SCLAlertView显示没有问题,但它背后的视图是纯白色。为什么会这样? UIAlertView是否会以某种方式突破后台线程?
我已尝试在后台线程中显示SCLAlertView,如下所示:objective c renderInContext crash on background thread但该应用仍然崩溃。
以下是我显示提醒的代码:
[PFCloud callFunctionInBackground:@"canWeStart"
withParameters:@{@"inviteId": self.selectedObject.objectId,
@"gameType": [[self.selectedObject objectForKey:@"GameType"] objectForKey:@"type"]}
block:^(NSArray *startStuff, NSError *error) {
if (!error) {
NSNumber *canStart = startStuff[0];
BOOL startBool = [canStart boolValue];
if(startBool)
{
//Stuff
}
else
{
//If I show this first, my alert shows perfectly.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Others" message:@"Need to accept" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[alert dismissWithClickedButtonIndex:0 animated:NO];
SCLAlertView *alert =
[[SCLAlertView alloc] init];
alert.backgroundType = Blur;
//button.layer.borderWidth = 2.0f;
[alert setTitleFontFamily:@"Alba" withSize:18.0f];
[alert setBodyTextFontFamily:@"Arista 2.0" withSize:14.0f];
[alert setButtonsTextFontFamily:@"Arista 2.0 Light" withSize:14.0f];
alert.customViewColor = [UIColor pxColorWithHexValue:@"2b3355"];
alert.backgroundViewColor = [UIColor whiteColor];
[alert showNotice:self.navigationController title:@"Invite Accepted" subTitle:@"Others still need to accept the invite, then the game will begin!" closeButtonTitle:@"Ok" duration:0.0f];
}
}
}];