2012-11-16 102 views
-1

我正在使用AdMob在我的UITableView中顯示廣告。它工作正常,但當廣告更改單元格時,我在表格中獲取空單元格。隱藏空UITableViewCell

我怎樣才能隱藏舊的和空的單元格?見圖片的問題

enter image description here

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    int row = [indexPath row]; 
    NSString *CellIdentifier = @"Cell"; 
    if(kAdFrequency - 1 == row%kAdFrequency){ 
     CellIdentifier = @"AdCell"; 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

     [cell addSubview:_banner]; 
     return cell; 
    }else{ 
     row = row - floor((float)row/kAdFrequency); 

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

     NGNationEventDay* day = [_events objectAtIndex:indexPath.section]; 
     NGNationEvent* event = [day.events objectAtIndex:row]; 

     cell.textLabel.text = event.name; 
     cell.detailTextLabel.text = event.category; 

     return cell; 
    } 
} 
+0

廣告更改地點如何?你可以發佈一些可能有助於解決問題的代碼嗎? – propstm

+0

我相信當[cell addSubView:_banner]被調用時,廣告正在改變單元格。我已經添加了代碼。 – ErikTJ

回答

0

我想一般這樣做的最好的辦法是公正,以確保您的廣告展示在那裏有決不會在兩個廣告單元的頻率最高屏幕一次(你可能只需修改kAdFrequency就可以了)。