ios - Expand and Shrink UIScrollView with animation -


i having uitableview inside scrollview. trying accordion component using uitableview. need expand uitableview add more cell. in case have increase height of uiscrollview animation matches table animation.

- (nsindexpath *)tableview:(uitableview *)tableview willselectrowatindexpath:(nsindexpath *)indexpath {     nsinteger row = [indexpath row];     bool preventreopen = no;      if (row == expandedrowindex + 1 && expandedrowindex != -1)         return nil;      [tableview beginupdates];     if (expandedrowindex != -1)     {         familytableview.frame = cgrectmake(familytableview.frame.origin.x, familytableview.frame.origin.y, familytableview.frame.size.width, 3*50+22);          toolstableview.frame = cgrectmake(toolstableview.frame.origin.x, familytableview.frame.origin.y + familytableview.frame.size.height + 20, toolstableview.frame.size.width, 4*50+22);          myaccounttableview.frame = cgrectmake(myaccounttableview.frame.origin.x, toolstableview.frame.origin.y + toolstableview.frame.size.height + 20, myaccounttableview.frame.size.width, 2*50+22);          settingsscrollview.contentsize = cgsizemake(320, familytableview.frame.size.height + toolstableview.frame.size.height+ myaccounttableview.frame.size.height + 380);         settingsscrollview.contentinset = uiedgeinsetsmake(0, 0, familytableview.frame.size.height + toolstableview.frame.size.height+ myaccounttableview.frame.size.height + 380, 0);          nsinteger rowtoremove = expandedrowindex + 1;          preventreopen = row == expandedrowindex;         if (row > expandedrowindex)             row--;         expandedrowindex = -1;         [tableview deleterowsatindexpaths:[nsarray arraywithobject:[nsindexpath indexpathforrow:rowtoremove insection:0]] withrowanimation:uitableviewrowanimationtop];     }else {         familytableview.frame = cgrectmake(familytableview.frame.origin.x, familytableview.frame.origin.y, familytableview.frame.size.width, (3*50+22) + 100);          toolstableview.frame = cgrectmake(toolstableview.frame.origin.x, familytableview.frame.origin.y + familytableview.frame.size.height + 20, toolstableview.frame.size.width, 4*50+22);          myaccounttableview.frame = cgrectmake(myaccounttableview.frame.origin.x, toolstableview.frame.origin.y + toolstableview.frame.size.height + 20, myaccounttableview.frame.size.width, 2*50+22);          settingsscrollview.contentsize = cgsizemake(320, familytableview.frame.size.height + toolstableview.frame.size.height+ myaccounttableview.frame.size.height + 380);         settingsscrollview.contentinset = uiedgeinsetsmake(0, 0, familytableview.frame.size.height + toolstableview.frame.size.height+ myaccounttableview.frame.size.height + 380, 0);     }     nsinteger rowtoadd = -1;     if (!preventreopen)     {         rowtoadd = row + 1;         expandedrowindex = row;         [tableview insertrowsatindexpaths:[nsarray arraywithobject:[nsindexpath indexpathforrow:rowtoadd insection:0]] withrowanimation:uitableviewrowanimationtop];      }     [tableview endupdates];      return nil; } 

i not @ animation. appreciated. need when [tableview beginupdates] have start animating resize effect uiscrollview , should end when [tableview endupdates] executes. accordion executes flawlessly. in advance help..

since changing view property (the frame of scroll view) recommend use uiview animation animate frame. may need tweak timing make perfect believe animation both easeineaseout , takes 0.4 seconds. animation this:

[uiview animatewithduration:0.4 animations:^{     // change animatable properties frames here...     yourscrollview.frame = thenewscrollviewframe; }]; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -