ios - Center UILabel after scrolling down -


i have problem centering label in scrollview. need user input 1 tab , based on data show results in tab. have set label tell user insert data if user taps tab without having inserted data first. works fine when user hasn't inserted data , presses results tab. looks this:

centered label http://i39.tinypic.com/2je2ruu.png

the problem appears when user has inserted data, scrolls way down, goes first tab, clears data , presses results tab again. label doesn't stay centered anymore:

noncentered label http://i44.tinypic.com/35kli75.png

i'm using auto layout mixed approach, have scrollview contentview inside that. when label displayed (i.e no data inserted) don't want view scroll, i'm doing this:

-(void)resultstabclicked {  if(dataisinserted) { mylabel.hidden = yes; self.contentviewheight.constant = resultsviewheight; self.scrollview.contentsize = cgsizemake(320, resultsviewheight); }  else { mylabel.hidden = no; self.contentviewheight.constant = 411; self.scrollview.contentsize = cgsizemake(320, 411); } } 

it works because when label in wrong place , first tab pressed , user still doesn't insert data , presses second tab again, voila! label in right place.

i'm experiencing same when there results displayed. depending on data result view height changes , again, when user scrolls down, goes first tab, changes data , goes results tab , results view happens smaller previous results view, top of result view cut off. , when user goes first tab, doesn't change , goes results tab, perfect again. have suggestions how make layout perfect first time view updated?


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -