简体   繁体   中英

dismissViewControllerAnimated not being called on iPhone

I have the following code where I am trying to show a PDF preview. It words perfectly on an iPad however when I am trying to do it on a iPhone it dosnt work.

QLPreviewController* preview = [[QLPreviewController alloc] init];
        preview.dataSource = self;
        [self dismissViewControllerAnimated:YES completion:^{
            [self presentViewController:preview animated:YES completion:nil];
        }];

The thread on the iPhone never makes it to this line

[self presentViewController:preview animated:YES completion:nil];

but works fine on ipad.. I am not sure what to even look at. Any help would be appreaciated.

要访问块内的实例/变量(在块外声明),您需要像这样声明这些实例/变量:__block类型标识符=初始值(可选),例如,在您的情况下,使用__block QLPreviewController * Preview = [[QLPreviewController alloc] init];

Try to use

[self.presentingViewController presentViewController:preview animated:YES completion:nil];

instead of

[self presentViewController:preview animated:YES completion:nil];

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