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
Post a Comment