2014-02-15 66 views
7

我正在將應用程序從iOS移植到OSX,OSX中是否有相當於UIActivityViewController的東西。對於Facebook,Twitter,郵件,信息分享等內容,我需要做類似的事情;在OSX中是否有相當於UIActivityViewController的東西?

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中實現此目的?

回答

7

對於OSX,我們可以使用NSSharingServicePicker這是非常相似的UIActivityViewController爲iOS:

NSSharingServicePicker *sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:urls]; 
sharingServicePicker.delegate = self; 

[sharingServicePicker showRelativeToRect:[sender bounds] 
             ofView:sender 
           preferredEdge:NSMinYEdge]; 
相關問題