336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
사용자가 WebView에서 스크롤을 맨 아래로 했는지 여부를 판단하기 위해 아래와 같이 작업해야 한다.

@interface TestViewController : UIViewController <UIGestureRecognizerDelegate>
{
     IBOutlet TestWebView *webview;
}

@implementation TestViewController

- (void)viewDidLoad
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizeralloc] initWithTarget:self 
  action:@selector(dummyHandle:)];
       tap.delegate = self;

    

       [webviewaddGestureRecognizer:tap];

}

- (void)dummyHandle:(UITapGestureRecognizer *)recognizer
{
        // webview의 touch를 감지
}

(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{

    int yPosition = 0;

    int offsetHeight = 0;

    int frameHeight = 0;


    yPosition = [[webview stringByEvaluatingJavaScriptFromString:@"scrollY"intValue];

    offsetHeight = [[webview stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"intValue];

    frameHeight = webview.frame.size.height;

    

    if(offsetHeight - yPosition <= frameHeight)

    {

  // 스크롤이 맨 밑으로 이동됨

    }

}


@end


위의 방식으로 처리하니 bottom체크를 여러번 하는 결과가 나오는데 아무래도 이벤트 방식이라서 Began, Changed, Ended를 처리하지 않아서인지 tap방식이 여러번 발생하는 태생적 결과인지 모르겠다. 여러번 체크하여 앱에 오동작을 유발하거나 버벅거림을 느낄 수 있어 좀 더 Smooth한 결과를 위해 아래와 같이 변경하였다.

UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizeralloc] initWithTarget:self  action:@selector(handleSwipeUp:)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeUp.delegate = self;
[webview.scrollViewaddGestureRecognizer:swipeUp];


- (void)handleSwipeUp:(UISwipeGestureRecognizer *)sender
{    
CGFloat scrollHeight = mWebView.scrollView.contentSize.height - mWebView.bounds.size.height;

        if(scrollHeight < 0.0f)
        scrollHeight = 0.0f;        

if(scrollHeight <= webview.scrollView.contentOffset.y + 50)    
{
     NSLog(@"bottom");
}    
else    
{       
NSLog(@"not bottom");     
}
posted by 어린왕자악꿍