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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:22:01+00:00 2026-05-23T12:22:01+00:00

I’m having a problem with what almost seems like a bug in iOS. I’m

  • 0

I’m having a problem with what almost seems like a bug in iOS. I’m trying to do some really simple scrolling in a UIScrollView. If I scroll to a point with an animation, it scrolls there perfectly fine, but it doesn’t set the point to the scrollView. I.E. when I scroll to somewhere else later, it jumps up to 0,0 and starts the animation from there.

I’m using the following code

[scrollView setContentOffset:CGPointMake(0, 95) animated:YES];
NSLog(@"offset x %@", [[NSNumber numberWithFloat:scrollView.contentOffset.x] stringValue]);
NSLog(@"offset y %@", [[NSNumber numberWithFloat:scrollView.contentOffset.y] stringValue]);

which produces output

offset x 0
offset y 0

while the exact same code with the animation off:

[scrollView setContentOffset:CGPointMake(0, 95) animated:NO];
NSLog(@"offset x %@", [[NSNumber numberWithFloat:scrollView.contentOffset.x] stringValue]);
NSLog(@"offset y %@", [[NSNumber numberWithFloat:scrollView.contentOffset.y] stringValue]);

produces output

offset x 0
offset y 95

I’m trying to automatically scroll to a UITextView so I’m listening to some keyboard notifications where I normally do the scrolling. But I’ve done this test in viewDidLoad and it produces these results.

Doing scrollView.contentOffset = CGPointMake(0,95); also sets the value correctly. It’s just the animated one that doesn’t.

Edit:
The code I am actually trying to run is this:

- (void)textFieldDidBeginEditing:(UITextField *)textField {
    //60 is half the available space in portrait mode so it puts the textfield in the centre.
    [self.scrollView setContentOffset:CGPointMake(0, textField.frame.origin.y-60) animated:YES];
}

Which scrolls the view to the correct position. But since it doesn’t seem to set contentOffset correctly it starts the animation from 0,0 all the time. Now matter how long I wait between the animations.

  • 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-23T12:22:02+00:00Added an answer on May 23, 2026 at 12:22 pm

    I would say both Gabriele’s and Dani’s answers are right. In your first snippet you’re actually trying to get final values before they’re set. That is, when you invoke this

    [scrollView setContentOffset:CGPointMake(0, 95) animated:YES];
    

    you basically start another thread, which animates your scrollView movement, and right away you try to get updated values. They’ll be updated by that second thread, and you can catch them in some delegate function, e.g. scrollViewDidScroll:, scrollViewDidEndScrollingAnimation: etc.

    BUT if you’re saying, that eventually your position isn’t being changed, then problem, I guess, is not here. I think you provided info, which doesn’t touch the problem itself.

    —If you’re working with table view, than you should check if you use

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    

    in your tableViewController class. And if you do, you should put the code with setOffset in its body instead of viewDidLoad.

    —If your textView is placed on some kind of popup window, like UIAlertView, and you want to place it properly, you should take a look at setTransform: method of UIAlertView. But as far as I know the problem with it is fixed in 4.2 version.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace

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.