I am having a problem integrating native ad into a Tableview. This tableview is complex it is using parse to get certain types of querys and then puts them into section types. I cannot figure out how to get the ads showing in the table view. The ad lots fine it shows the ad loading in the log.
Here is current code where I think the problem lies. If someone could help me out it would be greatly appreciated.
`- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
UITableViewCell *cell = [tableView mp_dequeueReusableCellWithIdentifier:kDefaultCellIdentifier forIndexPath:indexPath];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kDefaultCellIdentifier];
}
static NSString *CellIdentifier = @"Cell";
static NSString *TextIdentifier = @"TextCell";
static NSString *VideoIdentifier = @"VideoCell";
if (indexPath.section == self.objects.count) {
// this behavior is normally handled by PFQueryTableViewController, but we are using sections for each object and we must handle this ourselves
UITableViewCell *cell = [self tableView:tableView cellForNextPageAtIndexPath:indexPath];
return cell;
}
else if ([[object objectForKey:@"type"] isEqualToString:@"video"]) {
ESVideoTableViewCell *cell = (ESVideoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:VideoIdentifier];
if (cell == nil) {
cell = [[ESVideoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:VideoIdentifier];
[cell.mediaItemButton addTarget:self action:@selector(dummyTapForVideo:) forControlEvents:UIControlEventTouchUpInside];
}
cell.mediaItemButton.tag = indexPath.section;
cell.imageView.image = [UIImage imageNamed:@"PlaceholderPhoto.png"];
// cell.imageView.hidden= YES;
if (object) {
cell.imageView.file = [object objectForKey:@"videoThumbnail"];
[cell.imageView loadInBackground];
PFFile *video =[object objectForKey:@"file"];
[video getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"MyFile.m4v"];
[data writeToFile:appFile atomically:YES];
NSURL *movieUrl = [NSURL fileURLWithPath:appFile];
[cell.movie setContentURL:movieUrl];
}
}];
}
return cell;
}
else if ([[object objectForKey:@"type"] isEqualToString:@"text"]) {
ESTextPostCell *cell = (ESTextPostCell *)[tableView dequeueReusableCellWithIdentifier:TextIdentifier];
if (cell == nil) {
cell = [[ESTextPostCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TextIdentifier];
[cell.itemButton addTarget:self action:@selector(didTapOnTextPostAction:) forControlEvents:UIControlEventTouchUpInside];
}
cell.itemButton.tag = indexPath.section;
// cell.imageView.hidden= YES;
if (object) {
CGSize labelSize = [[object objectForKey:@"text"] sizeWithFont:[UIFont fontWithName:@"HelveticaNeue" size:16]
constrainedToSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 20, 100)
lineBreakMode:NSLineBreakByWordWrapping];
CGFloat labelHeight = labelSize.height;
cell.postText.frame = CGRectMake(10, 0, [UIScreen mainScreen].bounds.size.width-20, labelHeight+10);
cell.itemButton.frame = CGRectMake(10, 0, [UIScreen mainScreen].bounds.size.width-20, labelHeight+10);
cell.postText.text = [object objectForKey:@"text"];
}
return cell;
}
else {
ESPhotoCell *cell = (ESPhotoCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[ESPhotoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
[cell.mediaItemButton addTarget:self action:@selector(didTapOnPhotoAction:) forControlEvents:UIControlEventTouchUpInside];
}
cell.mediaItemButton.tag = indexPath.section;
cell.imageView.image = [UIImage imageNamed:@"PlaceholderPhoto.png"];
if (object) {
cell.imageView.file = [object objectForKey:kESPhotoPictureKey];
// PFQTVC will take care of asynchronously downloading files, but will only load them when the tableview is not moving. If the data is there, let's load it right away.
//if ([cell.imageView.file isDataAvailable]) {
[cell.imageView loadInBackground];
//}
}
return cell;
}
}`