曾幾何時,曾有一位iAd Banner工作完美。有一天,它決定在沒有明顯原因的情況下觸發EXC_BAD_ACCESS。iAd Banner導致EXC_BAD_ACCESS
所以我正在一個iOS屏幕上有一個iAd Banner的小遊戲。當bannerViewActionShouldBegin: willLeaveApplication:
被稱爲我發送NSNotification暫停遊戲,然後我返回TRUE
。 它曾經按預期方式工作,直到3天前,當敲擊旗幟開始引起EXC_BAD_ACCESS
與橫幅相關的代碼是這樣的:
標題:
@interface JAGameBackground : UIView <ADBannerViewDelegate>
{
...
ADBannerView *adBannerView;
}
主:
+(id)gameView
{
JAGameBackground *aBackground = [[JAGameBackground alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height + [UIScreen mainScreen].bounds.size.width)];
aBackground.adBannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
aBackground.adBannerView.delegate = aBackground;
[aBackground addSubview:aBackground.adBannerView];
...
return aBackground;
}
-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_PAUSE object:nil];
return TRUE;
}
and runni與儀器:
任何想法如何讓這個問題的童話結局?
在gameView的第一行看起來很可疑。它看起來像你的第二次爲JAGameBackground調用初始化器。 – Felix
第二次?我對它的理解是,它返回一個初始化實例 –
你應該創建一個類方法並用[[JAGameBackground alloc] initWithFrame創建實例:...] – Felix