ios - dismissViewControllerAnimated: completion: happens instantly unless I kludge it -


i have custom uiviewcontroller that's being displayed modally. i'm calling mainmenu.

it has own cute little transition animation make views slide off screen. when want dismiss it, want call custom animation , dismiss once that's done. seems should work:

- (void) dismisscustomviewcontroller {     [mainmenu slidemenupanelsaway];     [self dismissviewcontrolleranimated:yes completion:nil]; } 

however, makes view controller vanish instantly, before see custom slidey stuff.

what's right way make view controller wait until menus gone before vanishing?

i've tried bunch of things. found 1 way make work:

- (void) dismisscustomviewcontroller {     [mainmenu slidemenupanelsaway];     [self performselector:@selector(dismisscontroller) withobject:nil         afterdelay: 2.0f]; } 

(i wrote custom method called dismisscontroller make selector easier use, calls [self dismissviewcontrolleranimated:yes completion:nil];.)

it seems awful kludgey use manual delay setting instead of basing on completion of animation. there's got better way, doesn't there?

use animatewithduration:animations:completion:, , "slidey stuff" in animation block , dismissal in completion block.

[uiview animatewithduration:.5 animations:^{         //your custom animation stuff here      } completion:^(bool finished) {         [self dismissviewcontrolleranimated:yes completion:nil];     }]; 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -