在UIActivityViewController移动到父VC后,我需要提供一个视图
...
UIActivityViewController *avvc = [[UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];
[self presentViewController:avvc animated:YES completion:nil];
答案 0 :(得分:17)
Swift 3版本
avvc.completionWithItemsHandler = { (activityType, completed:Bool, returnedItems:[Any]?, error: Error?) in
if completed {
// Do something
}
}
答案 1 :(得分:11)
[avvc setCompletionHandler:^(NSString *activityType, BOOL completed) {
NSLog(@"after dismiss");
//Present another VC
}];
希望这对你有所帮助。
答案 2 :(得分:3)
我只想澄清一下,布尔值completed
代表单个UIActivity
的完成状态。如果UIActivityViewController
被撤消而没有采取任何措施,则activityType
的值为nil
,完成的值为false
。
[avvc setCompletionWithItemsHandler:^(UIActivityType _Nullable activityType, BOOL completed,
NSArray * _Nullable returnedItems,
NSError * _Nullable activityError) {
if (activityType == nil) {
NSLog(@"UIActivityViewController dismissed without any action.");
} else {
NSLog(@"completionWithItemsHandler, activityType: %@, completed: %d, returnedItems: %@, activityError: %@",
activityType, completed, returnedItems, activityError);
}
}];
答案 3 :(得分:2)
avvc.CompletionWithItemsHandler = MyCompletionWithItemsHandler;
// ...
void MyCompletionWithItemsHandler(NSString activityType, bool completed, NSExtensionItem[] returnedItems, NSError error)
{
if (completed)
{
// Did not tap Cancel
}
else
{
// Cancel was tapped
}
}