views:

20

answers:

0

I'm seeing an issue with UIScrollView and I can't figure out what's causing it.

Basically, I have a UIView w/ a UIScrollView. When the UIView is pushed onto the stack, an image & some text is displayed within the scrollview. From there the user can popViewController back to the original view. Simple enough...

The issue I'm seeing is that with the scrollView appears, the scroll is scrolled halfway down. Seems to be at random. Sometimes the scroll is @ the top.

Keep in mind both the heights of the image and the textView are dynamic.

in the ViewWillAppear method, I have this:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    CGSize textViewSize = self.myText.contentSize;
        CGRect textViewFrame = self.myText.frame;
    textViewFrame.size.height = textViewSize.height;
        self.myText.frame = textViewFrame;

    float imageHeight = myImage.image.size.height;
    float textViewHeight = textViewSize.height;

    [scrollView setScrollsToTop:YES];
    [scrollView setScrollEnabled:YES];
    [scrollView setContentOffset:CGPointMake(0.0, 0.0) animated:NO];    
    [scrollView setContentSize:CGSizeMake(320, imageHeight + textViewHeight)];

}

Any ideas as to what I'm doing wrong?

Thanks.