ios - Update uipopover height when cell is added -


i have table view (without scrolling) inside uipopovercontroller has 4 cells. , needs have cell (1 max). if animating adding , subtracting of cell, can update popover's height well?

here how create popover table view:

- (void)createpopovertable {      //set array     _arraylist = [nsmutablearray arraywithobjects:@"one", @"two", @"three", @"four", nil];       //make row selections persist.     self.clearsselectiononviewwillappear = no;       //view height     nsinteger rowscount = [_arraylist count];     nsinteger singlerowheight = [self.tableview.delegate tableview:self.tableview heightforrowatindexpath:[nsindexpath indexpathforrow:0 insection:0]];     nsinteger totalrowsheight = (rowscount * singlerowheight) + 20;      //view width     cgfloat largestlabelwidth = 0;     (nsstring *item in _arraylist) {         //check size of font using default label         cgsize labelsize = [item sizewithfont:[uifont boldsystemfontofsize:20.0f]];         if (labelsize.width > largestlabelwidth) {             largestlabelwidth = labelsize.width;         }     }      //some padding width     cgfloat popoverwidth = largestlabelwidth + 200;      //tell popover size     self.contentsizeforviewinpopover = cgsizemake(popoverwidth, totalrowsheight); } 

then in 1 of methods have code when table needs change:

[self.tableview beginupdates];  //update array [_arraylist insertobject:@"blue" atindex:3];  //insert row [self.tableview insertrowsatindexpaths:[nsarray arraywithobject:[nsindexpath indexpathforrow:3 insection:0]] withrowanimation:uitableviewrowanimationtop];  [self.tableview endupdates]; 

the code "works" fine when add cell, being cut off due non scrolling nature of popover controller. way can update that?

try 1 worked me

-(void) viewwillappear:(bool)animated {     [super viewwillappear:animated];     self.contentsizeforviewinpopover = self.tableview.contentsize; }  -(void) viewdidappear:(bool)animated {     [super viewdidappear:animated];     [self.popovercontrollercontainer setpopovercontentsize:self.contentsizeforviewinpopover animated:yes]; } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -