objective c - update UITableView sectionHeaderHeight at time of UIButton click in iOS -
good day! default tableview sectionheaderheight 56. want update when sectionopened method gets called.this following code:
- (void) sectionopened : (nsinteger) section { sectionheight = @"yes"; getsection = section; nslog(@"section clicked: %ld",(long)getsection); sectioninfo *array = [self.sectioninfoarray objectatindex:section]; array.open = yes; nsinteger count = [array.category.menulist count]; nsmutablearray *indexpathtoinsert = [[nsmutablearray alloc] init]; (nsinteger = 0; i<count;i++) { [indexpathtoinsert addobject:[nsindexpath indexpathforrow:i insection:section]]; } nsmutablearray *indexpathstodelete = [[nsmutablearray alloc] init]; nsinteger previousopenindex = self.opensectionindex; if (previousopenindex != nsnotfound) { sectioninfo *sectionarray = [self.sectioninfoarray objectatindex:previousopenindex]; sectionarray.open = no; nsinteger counts = [sectionarray.category.menulist count]; [sectionarray.sectionview togglebuttonpressed:false]; (nsinteger = 0; i<counts; i++) { [indexpathstodelete addobject:[nsindexpath indexpathforrow:i insection:previousopenindex]]; } } uitableviewrowanimation insertanimation; uitableviewrowanimation deleteanimation; if (previousopenindex == nsnotfound || section < previousopenindex) { insertanimation = uitableviewrowanimationtop; deleteanimation = uitableviewrowanimationbottom; } else { insertanimation = uitableviewrowanimationbottom; deleteanimation = uitableviewrowanimationtop; } [menulisttable beginupdates]; if(section==3 || section==4 || section==5) // section has cells submenu of menu { menulisttable.sectionheaderheight = 20.0; [menulisttable reloadsections:[nsindexset indexsetwithindex:section] withrowanimation:uitableviewrowanimationnone]; //[menulisttable reloadsections:[nsindexset indexsetwithindex:0] withrowanimation:uitableviewrowanimationnone]; } [menulisttable insertrowsatindexpaths:indexpathtoinsert withrowanimation:insertanimation]; [menulisttable deleterowsatindexpaths:indexpathstodelete withrowanimation:deleteanimation]; [menulisttable endupdates]; self.opensectionindex = section; }
but nothing happening. used indexsetwithindex:0. whats wrong in code?
try change height:
[menulisttable beginupdates]; menulisttable.sectionheaderheight = 20.0; [menulisttable endupdates];
edited:
take variable set sectionheaderheight. place code:
[menulisttable beginupdates]; secheaderheight = 20.0; [menulisttable endupdates]; - (cgfloat)tableview:(uitableview *)tableview heightforheaderinsection:(nsinteger)section { return secheaderheight; }
hope work you.
Comments
Post a Comment