0

此代码正在泄漏:

   self.adView = ADBannerView* tempAddBannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
self.adView.frame = CGRectOffset(adView.frame, 0, 416);
self.adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview:adView];
self.adView.delegate = self;
self.bannerIsVisible = NO;

显然是因为 adView 从未被释放。最好的释放地点在哪里?

我修复它的尝试崩溃了:

  ADBannerView* tempAddBannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    tempAddBannerView.frame = CGRectOffset(adView.frame, 0, 416);
    tempAddBannerView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
    tempAddBannerView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;


self.adView = tempAddBannerView;
[tempAddBannerView release];
[self.view addSubview:adView];
self.adView.delegate = self;
self.bannerIsVisible = NO;
4

1 回答 1

1

代码[self.view addSubview:adView];保留了,UIView所以你应该在该行之后安全地释放它。

于 2012-04-26T01:01:16.030 回答