Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:04:17+00:00 2026-06-06T15:04:17+00:00

I am new to iPhone developer, I made epub reader and loaded each page

  • 0

I am new to iPhone developer,

I made epub reader and loaded each page of epub in my webview, when i see my application in portrait mode scrolling is not there, bcoz i have used,

webview.scalesPageToFit=TRUE;

But when i see my application in landscape mode page fits properly but it occurs with scrolling, so i want to add swiperight gesture when scrolling end is reached so that user can navigate to a next page, on doing rightswipe.

is there any method which tells webview has completed scrolling ?


_ in short how to detect UIWebView reaching the top or bottom ?_

Thanks In Advance !

EDIT
written in did load:

    swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeRightAction:)];
    swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
    swipeRight.delegate = (id<UIGestureRecognizerDelegate>)self;
    [_webview addGestureRecognizer:swipeRight];

    swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
    swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
    swipeLeft.delegate = (id<UIGestureRecognizerDelegate>)self;
    [_webview addGestureRecognizer:swipeLeft];

and then while loading each page i am checking orientation if it is portrait then adding two more gesture up and down gesture if landscape then removing up and down gesture.

if([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortraitUpsideDown) {

        swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeLeftAction:)];
        swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
        swipeUp.delegate = (id<UIGestureRecognizerDelegate>)self;
        [_webview addGestureRecognizer:swipeUp];

        swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeRightAction:)];
        swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
        swipeDown.delegate = (id<UIGestureRecognizerDelegate>)self;
        [_webview addGestureRecognizer:swipeDown];

        counterPort++;
        counterLand=0;
      }
    }

    if (counterLand==0) {

        if([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationLandscapeRight) {

            [_webview removeGestureRecognizer:swipeDown];
            [swipeDown release];
            swipeDown=nil;

            [_webview removeGestureRecognizer:swipeUp]; 
            [swipeUp release];
            swipeUp=nil;

            counterPort=0;
            counterLand++;
        }

after your suggestion:

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    float scrollViewHeight = scrollView.frame.size.height;
    float scrollContentSizeHeight = scrollView.contentSize.height;
    float scrollOffset = scrollView.contentOffset.y;

    if (scrollOffset == 0)
    {
        swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeLeftAction:)];
        swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
        swipeUp.delegate = (id<UIGestureRecognizerDelegate>)self;
        [_webview addGestureRecognizer:swipeUp];  
    }
    else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
    {
        swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeRightAction:)];
        swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
        swipeDown.delegate = (id<UIGestureRecognizerDelegate>)self;
        [_webview addGestureRecognizer:swipeDown];
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:04:18+00:00Added an answer on June 6, 2026 at 3:04 pm

    In ios 5.0 and later, you can access the UIWebView's scrollView property. If you set that scrollView’s delegate to your object, you can find out when it reaches the top or bottom. Just make sure you hold a reference to the previous scrollview delegate before changing.

     _defaultDelegate=[webview.scrollView.delegate retain];
     webview.scrollView.delegate=myController;
    

    Your _defaultDelegate declaration will be

    id <UIScrollViewDelegate> _defaultDelegate;
    

    Now, in myController’s implementation of scrollViewDidScroll:, you can find out if the scrolling has reached the end or beginning of the page.

    The tricky thing is that you must implement other UIScrollViewDelegate Methods and pass on to the default delegate so that the webview does not lose its default behaviour. So, you implement like so

    - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
        [_defaultDelegate scrollViewDidScrollToTop:scrollView];
    }
    

    Refer to this answer for finding out if scrollView scrolls to top or bottom:
    iPhone – knowing if a UIScrollView reached the top or bottom

    EDIT: After reading your code, I don’t think you should be adding and removing your gesture recognizers like that. Create 4 gesture recognizers which covers all the possible swipe directions and add it to the webview in viewDidLoad. You can control if the gesture recognizer should respond by implementing the method :

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
    

    Don’t forget to set the delegate for each gesture recognizer and also checkout the other UIGestureRecognizerDelegate Methods. The view Controller has a property interfaceOrientation that you can access also.

    To solve the scrolling issue, try having a BOOL iVar to indicate if you are at the bottom in the code.

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
        float scrollViewHeight = scrollView.frame.size.height;
        float scrollContentSizeHeight = scrollView.contentSize.height;
        float scrollOffset = scrollView.contentOffset.y;
        _atBottom=NO;
        if (scrollOffset == 0)
        {
            swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeLeftAction:)];
            swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
            swipeUp.delegate = (id<UIGestureRecognizerDelegate>)self;
            [_webview addGestureRecognizer:swipeUp];  
        }
        else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
        {
            swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeRightAction:)];
            swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
            swipeDown.delegate = (id<UIGestureRecognizerDelegate>)self;
            [_webview addGestureRecognizer:swipeDown];
            _atBottom=YES;
        }
    }
    

    and implement the UIGestureRecognizerDelegate method

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
        return _atBottom;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to iPhone developer, I made epub reader and loaded each page
i am new to iPhone developer, i am creating ePub reader for reading ePub
I am new to iPhone developer, I have 4 page in my Application, my
I am iphone developer but now i am implementing cocoa application.I am new for
APPLICATION DESCRIPTION : I am a new iPhone developer. I am working on an
I am a new iPhone Application developer. I want to create an application which
I am new to iPhone Developer. i want to do navigate to new page
I am new to iPhone Developer, I want to detect touch in my webview
fairly new iPhone developer here. Building an app to send RS232 commands to a
I am a new iPhone developer and totally new to web-services as well. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.