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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:40:36+00:00 2026-05-18T05:40:36+00:00

I am trying to auto scroll my text view and reset it to the

  • 0

I am trying to auto scroll my text view and reset it to the top once it’s arrived at the end.

I use this code:

-(void)scrollTextView
{

    CGPoint scrollPoint = stationInfo.contentOffset; 

    scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 2);

    if (scrollPoint.y == originalPoint.y + 100)
    {
        NSLog(@"Reset it");

        scrollPoint = CGPointMake(originalPoint.x, originalPoint.y);
        [stationInfo setContentOffset:scrollPoint animated:YES];

        [scroller invalidate];
        scroller = nil;

        scroller = [NSTimer
                    scheduledTimerWithTimeInterval:0.1
                    target:self
                    selector:@selector(scrollTextView)
                    userInfo:nil
                    repeats:YES];

    }
    else
    {
        [stationInfo setContentOffset:scrollPoint animated:YES];
    }

}

As a result, the text view jumps around wildly, but I don’t quite know why. Is there maybe a better way of detecting that the text view is at the bottom? Am I setting the the scrollPoint value wrong?

Edit:

ISSUE SOLVED! I stuck to NSTimer – the missing key was calling -display for the layer.

    -(void)scrollTextView
    {
        //incrementing the original point to get movement
        originalPoint = CGPointMake(0, originalPoint.y + 2);
        //getting the bottom
        CGPoint bottom = CGPointMake(0, [stationInfo contentSize].height);
        //comparing the two to detect a reset
        if (CGPointEqualToPoint(originalPoint,bottom) == YES) 
        {
            NSLog(@"Reset");
            //killing the timer
            [scroller invalidate];
            scroller == nil;
            //setting the reset point
            CGPoint resetPoint = CGPointMake(0, 0);
            //reset original point
            originalPoint = CGPointMake(0, 0);
            //reset the view.
            [stationInfo setContentOffset:resetPoint animated:YES];
            //force display
            [stationInfo.layer display];

            scroller = [NSTimer
                        scheduledTimerWithTimeInterval:0.1
                        target:self
                        selector:@selector(scrollTextView)
                        userInfo:nil
                        repeats:YES];
        }
        else
        {   
            [stationInfo setContentOffset:originalPoint animated:YES];
        }


}
  • 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-18T05:40:37+00:00Added an answer on May 18, 2026 at 5:40 am

    You could also use CoreAnimation and animate the bounds property directly. First animate the scrolling, then in the delegate callback that the animation has finished you reset the content offset.

    The callback method has to have the signature

    - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    

    You could also use the new block-based methods if you are targeting iOS 4.0 and above. Then there are two blocks to be passed: in the first one you specify what to animate and in the second what to do when the animation is over.

    + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion
    

    Your problem than collapses into a single line of code:

    [stationInfo animateWithDuration:10.f delay:0.f options:0 animations:^{
        [stationInfo setContentOffset:CGPointMake(0, [stationInfo contentSize].height)];
    } completion:^(BOOL finished){
        if (finished) [stationInfo setContentOffset:CGPointMake(0,0)];
    }];
    

    To be honest I am not 100% sure about the precise block syntax but this is how it should work.

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

Sidebar

Related Questions

I am trying to auto-scroll to div using: /index.php#tabletabs2?contact_added=1 when I use: /index.php#tabletabs2 it
This is a test page I've put up: http://02ce746.netsolhost.com/tst/a.htm I am trying to auto-scroll
I'm trying to auto-generate a plain text email with a trademark symbol in it.
I am trying to auto-populate a text field based on the value of another
I was trying to write code that would auto-close a Toplevel Tk window in
im trying to getting auto complete working and i can do so fine when
I'm trying to create an auto-complete function for the ICSharpCode.TextEditor. But the fileTabs_KeyDown doesn't
I'm trying to create an auto generated post excerpt from the current page's post
I'm trying to set my Auto Properties but they are non-static and so I
I'm trying to make an auto login script and I'm stuck on the submit

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.