views:

120

answers:

2

Hi guys,

I'm experiencing something considered a bug in my situation. Probably this is not a bug but a feature ;).

Here's my case:

I load a UIScrollView with my content. A part of my content is loaded asynchrone after the view is already loaded. This works great and without issue. Some of these controls however are UITextView controls. Once I set the content (text property) of these controls after the viewDidLoad my UIScrollView scrolls down to the last UITextView that was set. I want to prevent this and want the UIScrollView to maintain it's top scrolled position.

In summary: If I set the Text property in the viewDidLoad method no scroll occurs. If I set the Text property on the UITextView after the viewDidLoad method (because I load the data asynchronous) the UIScrollView will scroll to the last UITextView that was set. I want to prevent this scroll.

How do I achieve this ? I have a feeling this is just a property which is set wrong but I can't seem to find it.

Thanks in advance.

EDIT:

I've tried setting the "scrollEnabled" property to NO before setting the values and to YES after but this didn't have any effect. The ScrollView will still scroll when the text property of the UITextView is set.

A: 

This would not change the scrolling problem but maybe make it "hidden" for the user:

yourTextView.text = @"Eat more bananas!";
yourScrollView.contentOffset = CGPointMake(0.0, 0.0);

Some snippets of your code would help to face the problem more specific.

EDIT: Or try to add the UITextViews to a UIView, then add the UIView to the UIScrollView. Make sure that the UIScrollView's contentSize is the same as the Size of the UIView.

Thorsten
A: 

I Fixed the issue with a work-around:

I set the scroll view content size to something small, like 320 x 300 or whatever the height of the scrollview frame is, then did my work, then put the content size back to normal.

This prevents the scrolling while the data is loaded and enables it as soon as the loading is finished.

Gidogeek