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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:15:55+00:00 2026-05-23T16:15:55+00:00

I have seen this question being addressed several times here at SO, e.g Problem

  • 0

I have seen this question being addressed several times here at SO, e.g Problem with UIScrollView Content Offset, but I´m still not able to solve it.

My iphone app is basically a tab bar controller with navigation bar. I have a tableview controller made programmatically and a DetailViewController that slides in when I tap a cell in my tableview controller.

The DetailViewController is made in IB and has the following hierarchy:

top view => UIScrollView => UIView => UIImage and a UITextField.

My goal is to be able to scroll the image and text field and this works well. The problem is that my UIScrollView always gets positioned at the bottom instead at the top.

After recommendations her at SO, I have made my UIScrollView same size as the top view and instead made the UIView with the max height (1500) of my variable contents.

In ViewDidLoad I set the contentSize for the UIScrollView (as this is not accessible from IB):

- (void)viewDidLoad {

  [scrollView setContentSize:CGSizeMake(320, 1500)];
  [scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
  NSLog(@"viewDidLoad: contentOffset y: %f",[scrollView contentOffset].y);
}

Specifically setting the contentOffset, I would expect my scrollView to always end up at the top. Instead it always go to the bottom. It looks to me that there is some autoscrolling beyond my control taking place after this method.

My read back of the contentOffset looks OK. It looks to me that there may be some timing related issues as the scrolling result may vary whether animation is YES or NO.

A ugly workaround I have found is by using this delegate method:

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrView {
    NSLog(@"Prog. scrolling ended");
    [scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
}

This brings my scrollview to top, but makes it bounce down and up like a yo-yo

Another clue might be that although my instance variables for the IBOutlet are set before I push the view controller, the first time comes up with empty image and textfield:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath  *)indexPath {

    if (!detailViewController) {
       detailViewController = [[DayDetailViewController alloc] init];
    }

    // Pass dictionary for the selected event to next controller
    NSDictionary *dict = [eventsDay objectAtIndex:[indexPath row]];
    // This method sets values for the image and textfield outlets
   [detailViewController setEventDictionary:dict];  

    // Push it onto the top of the navigation controller´s stack.
    [[self navigationController] pushViewController:detailViewController animated:NO];


}

If I set animation to YES, and switch the order of the IBOutlet setting and pushViewController, I can avoid the emptiness upon initialization. Why?

Any help with these matters are highly appreciated, as this is really driving me nuts!

  • 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-23T16:15:56+00:00Added an answer on May 23, 2026 at 4:15 pm

    Inspired of Ponchotg´s description of a programmatically approach, I decided to skip interface builder. The result was in some way disappointing: The same problem, with the scrollview ending up in unpredictable positions (mostly at bottom), persisted.

    However, I noticed that the scroll offset error was much smaller. I think this is related to the now dynamic (and generally smaller) value of ContentOffset. After some blind experimenting I ended up setting

    [textView setScrollEnabled:YES];
    

    This was previously set to NO, as the UITextView is placed inside the scrollview, which should take care of the scrolling. (In my initial question, I have erroneously said it was a UITextField, that was wrong)

    With this change my problem disappeared, I was simply not able to get into the situation with scrollview appearing at bottom anymore in the simulator! (At my 3G device I have seen a slight offset appear very seldom, but this is easily fixed with scrollViewDidEndScrollingAnimation delegate described previously ).

    I consider this as solved now, but would appreciate if anyone understand why this little detail messes up things?

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

Sidebar

Related Questions

I have seen this question being asked multiple times on the R mailing list,
I've seen this question being asked 1000 times, but I'd tried almost all methods
Now I have seen this question in another forum but it didn't had an
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
This question seems to have been asked a lot, but I haven't seen an
I have seen different questions regarding this, but I still find this topic to
I have seen this question posed regarding Silverlight 2 but I have not seen
I've seen this multiple times in multiple places, but never have found a satisfying
I have seen several similar questions to this, but none that addresses my specific
Okay, so I've seen this question about this problem being caused by multiple linkings

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.