objective c - iOS - Add view without knowing its size -


i trying, programmatically, add subviews view. process goes follows:

1) fetch array of medias web

2) if picture, build uiimageview , add bottom of view. if text, build uitextview , add bottom of view

3) repeat step 2 until end of array

the problems:

  • how create views if don't know height of them? seems add view need specify frame.

  • how add each view bottom of existing views?

thanks in advance, tiago

if don't know size of view, call sizetofit , layoutifneeded method after adding view. here's code:

objective-c :

[superview addsubview: view];  [view sizetofit];  [view layoutifneeded]; 

swift :

superview.addsubview(view) view.sizetofit() view.layoutifneeded() 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -