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 1838476
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:28:57+00:00 2026-05-17T06:28:57+00:00

I have a UIScrollView subclass that I am programmatically scrolling using UIView animations. I’d

  • 0

I have a UIScrollView subclass that I am programmatically scrolling using UIView animations.

I’d like the user to be able to tap or zoom into the UIImageView content of the Scroll View while the animation is taking place.

This has worked fine while using a formulation akin to this:

- (void) scrollSmoothlyatPixelsPerSecond:(float)thePixelsPerSecond {
    // distance in pixels / speed in pixels per second
    float animationDuration = _scrollView.contentSize.width / thePixelsPerSecond;

    [UIView beginAnimations:@"scrollAnimation" context:nil];
    [UIView setAnimationCurve: UIViewAnimationCurveLinear];
    [UIView setAnimationDuration:animationDuration];
    _scrollView.contentOffset = CGPointMake(_scrollView.contentSize.width, 0);
    [UIView commitAnimations];
}

Now, since iOS 4.0, UIView beginAnimations: is discouraged. So I tried to update my code using a block and UIView animateWithDuration: The scrolling works identically to the above.

The key and maddening difference is that during animation, the UIScrollView and other views no-longer respond to event handling methods:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; 

Nor does :

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;

get called when trying to zoom.

Edit for clarity : No UIView present responds to touch events. This isn’t limited to just the UIScrollView. The UIScrollView’s peer a UIToolbar does not respond to touch events, nor do other buttons that are subviews of a peer to the UIScrollView. It appears that the entire parent UIView is frozen out of user interaction while the animation is going on. Again, after the animation completes, all of the above UIViews are again responsive.

These all do get called in the UIView beginAnimations: formulation regardless of animation state.

My animateWithDuration: code is slightly different – but the differences are not material. As soon as the animation completes, the above touch events are again called…

here’s my animate code:

- (void) scrollSmoothlyToSyncPoint:(SyncPoint *) theSyncPoint andContinue:(BOOL)theContinueFlag{

    float animationDuration = theSyncPoint.time - [player currentTime];
    [UIView animateWithDuration:animationDuration 
                          delay:0 
                        options:UIViewAnimationOptionCurveLinear 
                     animations:^{
        [_scrollView setContentOffset:theSyncPoint.contentOffset];
    } 
                     completion:^(BOOL finished){
                         if (theContinueFlag) {
                             SyncPoint *aSyncPoint = [self nextSyncPoint];
                             if (aSyncPoint) {
                                 [self scrollSmoothlyToSyncPoint:aSyncPoint andContinue:YES];
                             }
                         }
    }];
}

The only event handler that fires during the above animation block is:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;

So, question: Should I – ignore Apple’s discouraged label and continue to use the beginAnimation formulation? Should I – reimplement zooming and my other touch-based events using hitTest? Is there some knowledge of the difference in implementation between animation blocks that can help me confront this problem? Is there something obvious that I’m missing?

I am a new developer to Apple, and so I don’t know how seriously to take their discouraged tag. But if this API will be deprecated then disappear, I’d rather move in a lasting direction.

thanks so much for your attention.

  • 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-05-17T06:28:57+00:00Added an answer on May 17, 2026 at 6:28 am

    You just need to include the UIViewAnimationOptionAllowUserInteraction option when invoking the animation like so:

    [UIView animateWithDuration:animationDuration 
                              delay:0 
                            options:(UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
                         <snip>];
    

    That’s a sneaky one, I know! 😉

    Re: The “Discouraged” tag – In general, when Apple tells you not to do something in regards to designing applications that run on their platforms, it’s usually for your own good. So you are right in wanting to adopt animation blocks instead of the clunky old way.

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

Sidebar

Related Questions

I'm using an UIScrollView and I have an image that indicates to the user
I have a UIScrollView that houses a gallery of images the user can scroll
I have a subclass of UIScrollView that overrides touchesBegan:withEvent: touchesMoved:withEvent: touchesEnded:withEvent: Overriding these three
I have a subclass of UITableViewController that works as expected. I'd like to capture
I have a root UIView with two subviews: a custom UIView subclass a UIScrollView
I have a UIScrollView decendent that implements a takeScreenshot method that looks like this:
I have a UIScrollView that shows vertical data, but where the horizontal component is
I have a Graph being drawn inside a UIScrollView . It's one large UIView
I have 6 UITextFields on my UIScrollView . Now, I can scroll by user
in my application I use have the following views hierarchy: UIView ----UIScrollView --------TiledView (UIView

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.