如何在UITableView ios中重用已经加载的标题视图

时间:2013-09-03 09:46:20

标签: ios uitableview

我正在尝试在- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section上使用Google广告,

实际上,我需要使用线程来展示广告,而不会让谷歌广告崩溃应用程序。

在20个单元格之后的UITableView的每个部分中,我想要显示广告。

但我的问题是每当我向上和向下滚动时都需要时间来重新加载广告,例如,如果我在第一部分广告加载后我移动到部分广告加载当我再次回到第一部分时旧广告视图将被删除,新广告视图正在加载。

所以我想要的是我想重新使用第一部分的旧广告视图,只有在每次应重复使用旧广告视图时才应加载广告。这是viewForHeaderInSection

中的代码
 [[NSOperationQueue mainQueue] addOperationWithBlock:^{

// Create a view of the standard size at the top of the screen.
// Available AdSize constants are explained in GADAdSize.h.
 adBanner_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
adBanner_.adUnitID = @"a15120dbc353a5f";

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
adBanner_.rootViewController = self;

// Initiate a generic request to load it with an ad.
[adBanner_ loadRequest:[GADRequest request]];

}];

return adBanner_;

如果该部分视图已经加载,请任何人告诉我如何重新使用第一,第二和第三......部分。

由于

0 个答案:

没有答案