如何分享內容到系統中的分享平台如Facebook/Twitter/Line/Email?
ex:
-(IBAction)shareButtonClicked:(UIButton *)button { UIImage *exImage = [UIImage imageNamed:@"ex.jpg"]; UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObjects:@"Message", exImage, nil] applicationActivities:nil]; [self presentViewController:avc animated:YES completion:nil]; }
上面是透過 UIActivityViewController 來分享而不是透過 UIDocumentInteractionController 的 presentOpenInMenuFromRect。
如何透過 UIActivityViewController 放附件?
try this
NSData *pdfData = [NSData dataWithContentsOfFile:pdfFilePath];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Test", pdfData] applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
and also
NSString *str = [[NSBundle mainBundle] pathForResource:@"AppDistributionGuide" ofType:@"pdf"];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[@"Test", [NSURL fileURLWithPath:str]] applicationActivities:nil];
相關文章:
http://nshipster.com/uiactivityviewcontroller/