我正在将应用程序从iOS迁移到OSX,在OSX中是否有类似于UIActivityViewController的东西。对于像Facebook,Twitter,邮件,消息共享这样的东西,我需要做类似的事情;
NSArray *activityItems = [NSArray arrayWithObjects:shareString, shareImage, shareUrl, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];
activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:activityViewController animated:YES completion:nil];
如何在OSX中实现这一目标?
答案 0 :(得分:8)
对于OSX,我们可以使用NSSharingServicePicker,它与iOS的UIActivityViewController非常相似:
NSSharingServicePicker *sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:urls];
sharingServicePicker.delegate = self;
[sharingServicePicker showRelativeToRect:[sender bounds]
ofView:sender
preferredEdge:NSMinYEdge];