2

I'm trying to determine when a tableHeaderView or tableFooterView is actually rendered on the screen. The problem I'm facing is I can only have 1 ad view rendered at a time. If I put it in the header and then the footer, it removes it from the header. So what I want to do is, when the footer shows up on the screen, move the ad view into the footer and when the header shows up on the screen, move the ad view into the header.

Right now I'm loading 2 separate ads and dropping them in each, but we want the same ad on each and the ad server recommends only loading a single ad and moving it around to where it needs to be displayed.

Kevin
  • 401
  • 3
  • 10

1 Answers1

1

You can use the scrollview delegate to calculate manually when each view is off the screen

This post has what you need I believe

https://stackoverflow.com/a/27868948/4875095

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

static CGFloat lastY = 0;

CGFloat currentY = scrollView.contentOffset.y;
CGFloat headerHeight = self.headerView.frame.size.height;

if ((lastY <= headerHeight) && (currentY > headerHeight)) {
    NSLog(@" ******* Header view just disappeared");
}

if ((lastY > headerHeight) && (currentY <= headerHeight)) {
    NSLog(@" ******* Header view just appeared");
}

lastY = currentY;

}

Community
  • 1
  • 1
RyanOfCourse
  • 832
  • 1
  • 8
  • 15