Frage

I have created a UIScrollView using storyBoard. I wanted to add few labels and buttons in that. At very first time, when I add label using following method it is not visible.

int _x=0,_y=0;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(_x,_y, stringsize.width, stringsize.height)];

But, When I set _y position as -62 then it is visible as expected.

I have tried to invoke following methods before adding label to UiScrollView to fix this issue. But nothing works.

[scrollview.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
scrollview.contentSize = CGSizeMake(scrollview.frame.size.width, 0);
[scrollview setContentOffset:CGPointMake(0, 0) animated:YES];

Basically the issue is during first time launch of UIscrollView the Y position is not set properly.

War es hilfreich?

Lösung

After disabling "Adjust Scroll View Insets"option in storyboard. It is working as expected. Thanks Finn! –

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top