ios - Summing the heights of the views inside my stackview -


hey im working on rss blog reader component app , i’m running issue of sizing stack view containing textviews , image views of parsed blog content. sizing issue comes fact can’t proper heights of individual textviews , image views.

please excuse gaps in ios knowledge. i've been teaching myself these issues catch me on basic level.

i tried doing few other stack overflow questions recommended adding

self.view.setneedsdisplay() self.view.setneedslayout() 

but it’s not working.

here’s link app (just 1 view controller, <200 sloc) https://github.com/stanchiang/parsingrss

    func feedparser(parser: mwfeedparser, didparsefeeditem item: mwfeeditem) {         var scrollview = uiscrollview()         scrollview = uiscrollview(frame: self.view.frame)         scrollview.translatesautoresizingmaskintoconstraints = false         self.view.addsubview(scrollview)          let stackview = uistackview(arrangedsubviews: restructuretext(item.summary) as! [uiview])         stackview.frame = cgrectmake(0, 0, self.view.frame.width, self.view.frame.height * 6)         stackview.axis = uilayoutconstraintaxis.vertical         stackview.distribution = uistackviewdistribution.fillproportionally         scrollview.addsubview(stackview)          self.view.setneedsdisplay()         self.view.setneedslayout()          var fullheight:cgfloat = 0.0         view in stackview.arrangedsubviews {             if view.iskindofclass(uitextview) {                 let tv:uitextview = view as! uitextview                 print("textview: \(tv.frame.size)")             }             if view.iskindofclass(uiimageview) {                 let tv:uiimageview = view as! uiimageview                 print("imageview: \(tv.frame.size)")             }             fullheight += view.intrinsiccontentsize().height         }         print("new:\(fullheight) vs old:\(stackview.frame.height)")         scrollview.contentsize = stackview.frame.size          parser.stopparsing()     } 


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -