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

  • Home
  • SEARCH
  • 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 8722777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:29:19+00:00 2026-06-13T07:29:19+00:00

I am building an iPad app where I needed to allow resizing views functionality

  • 0

I am building an iPad app where I needed to allow resizing views functionality using divider view provided between two views. The divider view is just a 20px height view between two half screen content views – please refer attached images.

When user scrolls this divider view up or down, both content views changes their sizes appropriately. I have extended UIView and implemented this using touchMoved delegate as code given below in touchesMoved delegate. It works fine. The only thing is missing with TouchMoved is you can’t flick divider view to top or bottom directly. You have to drag all the way to top or bottom!

To support flicking the view I have tried UIPanGestureRecognizer but I don’t see smooth dragging with it. Setting split-position of parent resizes both content views as shown in the code. When I handle split position change in UIGestureRecognizerStateChanged state, just touching divider view flick it to top or bottom. Handling split position change in UIGestureRecognizerStateEnded does the same but I don’t see content view resizing with dividerview scrolling!

Could someone please tell me how could I achieve both smooth scrolling of divider view with resizing content views (like touchMoved) and flicking the view? Any alternative approach would also be fine. Thanks.

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    if (touch) {
        CGPoint lastPt = [touch previousLocationInView:self];
        CGPoint pt = [touch locationInView:self];
        float offset = pt.y - lastPt.y;
        self.parentViewController.splitPosition = self.parentViewController.splitPosition + offset;
    }
}

- (void)handlePan:(UIPanGestureRecognizer*)recognizer {

    CGPoint translation = [recognizer translationInView:recognizer.view];
    CGPoint velocity = [recognizer velocityInView:recognizer.view];

    if (recognizer.state == UIGestureRecognizerStateBegan) {
    } else if (recognizer.state == UIGestureRecognizerStateChanged) {
       // If I change split position here, I don't see smooth scrolling dividerview...it directly jumps to the top or bottom!
       self.parentViewController.splitPosition = self.parentViewController.splitPosition + translation.y;
    } else if (recognizer.state == UIGestureRecognizerStateEnded) {
      // If I change split position here, the same thing happens at end and I don't see my divider view moving with my scrolling and resizing my views.
        self.parentViewController.splitPosition = self.parentViewController.splitPosition + translation.y;
    }
}

Initial screen

Initial screen

Increased top view size by scrolling divider view towards bottom.

Increased top view size by scrolling divider view

Top view is totally hidden here but I have to scroll divider view all
the way to top. I want to flick the divider view so that it directly
goes from any position to top

Top view is totally hidden here but I have to scroll divider view all the way to top. I want to flick the divider view so that it directly goes from any position to top.

  • 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-13T07:29:20+00:00Added an answer on June 13, 2026 at 7:29 am

    If I understand you correctly, you have two separate problems here.

    1st: The ‘unsmooth’ dragging when using the GestureRecognizer. The problem in your code is, that you add the translation every time the GR calls it’s handle method. Since the translation is measured continuously, you’re adding a higher value every time it’s called (i.e. the first call adds 10 to the split position, the 2nd 20, the 3rd 30 and so on).

    To solve this you should set the translation to zero after you’ve updated the split position:

    - (void)handlePan:(UIPanGestureRecognizer*)recognizer {
    
        CGPoint translation = [recognizer translationInView:recognizer.view];
    
        if (recognizer.state == UIGestureRecognizerStateChanged) {
           self.parentViewController.splitPosition = self.parentViewController.splitPosition + translation.y;
        } 
        [recognizer setTranslation:CGPointZero inView:recognizer.view];
    }
    

    2nd: To allow the user to flick the split position to the top or bottom, you could check the velocity in UIGestureRecognizerStateEnded, and if it exeeds some value instantly set the splitposition to top or bottom.

    But it might be more convenient to use a UISwipeGestureRecognizer.

    - (void)handleSwipe:(UISwipeGestureRecognizer *)gr
    {
        if (gr.direction == UISwipeGestureRecognizerDirectionUp){
            [self.parentViewController moveSplitViewToTop];
        }
        else if (gr.direction == UISwipeGestureRecognizerDirectionDown){
            [self.parentViewController moveSplitViewToBottom];
        }
    }
    

    In this case it might be necessary (not sure, maybe it’s not) to require the SwipeGR to fail before the PanGR triggers by setting:

    [panGestureRecognizer requireGestureRecognizerToFail:swipeGestureRecognizer];
    

    Hope that helped.

    Edit:
    Regarding your comment, I assume by frequency you mean velocity. If you only use the PanGR you could modify the code above to sth. like this:

    - (void)handlePan:(UIPanGestureRecognizer*)recognizer {
    
        CGPoint translation = [recognizer translationInView:recognizer.view];
        CGPoint velocity = [recognizer velocityInView:recognizer.view];
    
        if (recognizer.state == UIGestureRecognizerStateChanged) {
           self.parentViewController.splitPosition = self.parentViewController.splitPosition + translation.y;
        } 
        else if (recognizer.state == UIGestureRecognizerStateEnded){
            if (velocity.y > someValue){
                [self.parentViewController moveSplitViewToBottom];
            }
            else if (velocity.y < someValue){
                [self.parentViewController moveSplitViewToTop];
            }
        }
        [recognizer setTranslation:CGPointZero inView:recognizer.view];
    }
    

    I’m not sure if the velocity is signed, if not you’ve got to check for the translation again in the if-block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an iPad app where all views should autorotate. One view is
I am building an iPad app using Flash CS6 to compile to AIR 3.3
I'm building an iPad app with views that are split horizontally and animate in
I am building an iPad app that has a split view controller. Is it
Building an iPad app. I have a button on my main view that I
I'm building an iPad app using storyboards. In Interface Builder (XCode 4.5), the nav
I am building an app for iPhone and iPad using PhoneGap and jQM <div
I'm building a simple puzzle app for and iPad using a JavaScript library for
so i'm building a mobile safari iPad app using jquerymobile... I was using this
Possible Duplicate: iPad Web App: Detect Virtual Keyboard Using JavaScript in Safari? I'm building

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.