ios - UITableView height inside UIScrollView in Swift -


i'm trying add uitableview inside uiscrollview when set height of uitableview using tableview.contentsize.height not setting height (it add height whats actual height is)

can please help?

this want achieve

i able make content size of table set table height , modify content size of scrollview following way.

i designed table inside scrollview , call modify height of table , content size of scrollview viewdidappear

my code :

override func viewdidload() {     super.viewdidload()     // additional setup after loading view, typically nib.      self.extradesignafterstoryboard(); }  override func viewdidappear(animated: bool) {      self.modifycontentheight(); }  func extradesignafterstoryboard() {     scrolvw = uiscrollview();     scrolvw.frame = cgrectmake(0, 64, self.view.frame.size.width, 200);     scrolvw.backgroundcolor = uicolor.greencolor();     self.view.addsubview(scrolvw);      tblviewscr = uitableview(frame: cgrectmake(0, 80, scrolvw.frame.size.width, 120), style: uitableviewstyle.plain);     tblviewscr.delegate = self;     tblviewscr.tag = 100;     tblviewscr.datasource = self;     tblviewscr.scrollenabled = false;     tblviewscr.backgroundcolor = uicolor.redcolor();     scrolvw.addsubview(tblviewscr); }  func modifycontentheight() {     if(self.tblviewscr.contentsize.height > self.tblviewscr.frame.height){         var frame: cgrect = self.tblviewscr.frame;         frame.size.height = self.tblviewscr.contentsize.height;         self.tblviewscr.frame = frame;          var contentsize = self.scrolvw.contentsize;         contentsize.height = cgrectgetmaxy(self.tblviewscr.frame);         self.scrolvw.contentsize = contentsize;     } } 

it working here in demo project. can check once, if works you.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -