简体   繁体   中英

dismissViewControllerAnimated completion block is not called

I'm trying to dismiss a view controller like this:

[composeViewController dismissViewControllerAnimated:YES completion:^{

    NSLog(@"Hello"); // Never outputted
}];

The view controller is dismissed, but for some reason the completion block is never called.

I have never had any issues with completion block not being called with other view controllers.

This view controller is "special" though, because it's added as a child view controller (which I have not worked with previously in my app). Does this impose any side effects why the completion block is not called?

It's added like this:

UIViewController *rootVC = [UIApplication sharedApplication].delegate.window.rootViewController;
[rootVC addChildViewController:self];
[rootVC.view addSubview:self.view];
[self didMoveToParentViewController:rootVC];

找出问题所在:我使用的第三方视图控制器已被覆盖- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion而不实际调用completion()

If you present a modal, is the view controller that receive the message (or the top in hierarchy , I still didn't get that) that handles all the process of adding the child vc swapping view etc. It seems that you are doing a mix of the two techniques. Just use one.
So present it using - (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion ad dismiss it using dismissViewController let the view controller manages everything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM