ios - How can I get the correct sizes for UIViews created in storyboard during runtime -


i created uiview using storyboard, set constraints. when ran application, interface looked fine. view covered entire screen supposed (i made background color black it's easier see what's going on).

http://contentlibrary.sinaapp.com/view%20from%20storyboard.png (i'm sorry have link images in this, system says need @ least 10 rep post images.)

however, when tried size of view using myview.bounds.size. got (600, 580), size appeared in storyboard's size inspector.

i created uiview in code

var myview = uiview(frame: cgrect(x: 0, y: 20, width: 600, height: 580)) 

and added subview top-level view. appeared didn't cover entire screen view created in storyboard. both view created in storyboard , in code have same value in .bounds.size, appeared have different sizes on screen. (this picture view created in code. see there white space @ bottom of screen.)

http://contentlibrary.sinaapp.com/view%20from%20code.png

another interesting thing is, if replace above uiview uiscrollview, after scroll view zoomed, update correct size. added uiscrollview same way added uiview using storyboard. tried print size inside delegate method scrollviewdidendzooming:withview:atscale:. says (375.0, 647.0), correct on-screen size view covers entire screen on iphone 6.

judging this, seems views come out of storyboard don't automatically update correct on-screen sizes.

so how uiview object created in storyboard update size?

sounds you're checking size early.

try put code in viewdidlayoutsubviews method , see if it's going change.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -