UIActivityViewControllerCompletionHandler How to?

后端 未结 5 1753
予麋鹿
予麋鹿 2021-02-02 10:05

I am trying to use the UIActivityViewControllerCompletionHandler , but i dont quite get how..

I want to detect when the user finishes or dismisses this

5条回答
  •  野的像风
    2021-02-02 10:53

    Here's how you show a sharing dialog and set its completion handler

    NSArray *imageArray = [NSArray arrayWithObject:shareImage];
    
    UIActivityViewController *sharing = [[UIActivityViewController alloc] initWithActivityItems:imageArray applicationActivities:nil];
    
    [sharing setCompletionHandler:^(NSString *activityType, BOOL completed) {
        NSLog(@"completed dialog - activity: %@ - finished flag: %d", activityType, completed);
    }];
    
    [self presentViewController:sharing animated:YES completion:nil];
    

提交回复
热议问题