Ron
Ron

Reputation: 1047

presentViewController with dismiss block

This is what I would like. Present a UIViewController (UITableViewController) and in the presentViewController method incorporate a dismiss block.

So something like this:

[self presentViewController:vc 
    animated:YES 
    completion:nil 
    onDismiss:^{
        NSLog(@"dismissed")
    }
];

I tried implementing This SO solution because it looks like the exact thing of what I need but didn't quite figure out how it should be done. Anyone that can provide me with a detailed description?

Thanks!

Upvotes: 3

Views: 3619

Answers (1)

Shizam
Shizam

Reputation: 9672

To clarify the discussion in the comments:

In your ContainerViewController's header define this function:

-(void)presentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^)(void))completion dismissCompletion:(dispatch_block_t)dismissCompletion

and follow the rest of the instructions for the implementation of the function for ContainerViewController from here

Then in your ViewController call

[containerViewController presentViewController:presentedViewController animated:YES completion:<whatever> dismissCompletion:<whatever>]

If you're calling this from within a ContainerViewController you can call it on self if you're in SomeOtherViewController with a ContainerViewController (CVC) object call it on the CVC object.

Upvotes: 3

Related Questions