UIActivityViewController Share text in whats app and all sharing option

后端 未结 1 1642
-上瘾入骨i
-上瘾入骨i 2021-01-19 23:31

In my application I used UIActivityViewController to share text in Whatsapp, Facebook and Twitter etc.

I am working in iOS 9 and Xcode Version 7.2. When

相关标签:
1条回答
  • 2021-01-19 23:43

    I had that problem.. It is caused most probably by using NSString instead of NSURL, here is a working code:

    -(void) share {
    NSString* shareText = @"Sharing an eddress with you";
    NSURL *website = [NSURL URLWithString:@"http://eddress.co/EDDRSS"];
    NSArray *shareArray = @[shareText, website];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:shareArray applicationActivities:nil];
    
    [activityVC setValue:@"Someone shared an eddress with you" forKey:@"subject"];
    
    NSArray *excludeActivities = @[UIActivityTypeAirDrop,
                                   UIActivityTypePrint,
                                   UIActivityTypeAssignToContact,
                                   UIActivityTypeSaveToCameraRoll,
                                   UIActivityTypeAddToReadingList,
                                   UIActivityTypePostToFlickr,
                                   UIActivityTypePostToVimeo];
    
    activityVC.excludedActivityTypes = excludeActivities;
    
    [self.navigationController presentViewController:activityVC animated:YES completion:nil];
    }
    
    0 讨论(0)
提交回复
热议问题