I am not able to see any item in UIActivityViewController. I want to share Audio file to Available Sharing options in iPhone device.
Review this doc, it will help you.
NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
NSString *filePath = [docPath stringByAppendingPathComponent:@"sound.aac"];//Audio file
NSURL *fileUrl = [NSURL fileURLWithPath:filePath isDirectory:NO];
NSArray *activityItems = @[fileUrl];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
Above answer worked for me after little bet struggle.I think there is some issue to access file path .here is modified and tested code.
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"sampleFile" ofType:@"mp3"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSArray *activityItems = @[soundFileURL];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.