0

I have in my app a UIWebView like Safari I need now to share the web url.

I am using this code:

- (IBAction)shareLink:(id)sender
{
    NSURL *newsURL = myWebView.request.URL;

// 1. url = http://www.alhikmeh.org/news/archives/43645        
// 2. other url = http://www.alhikmeh.org/news/wp-content/uploads/2015/04/24-4-2015-9d.jpg


    if ([newsURL isFileReferenceURL]) {
        NSData *data = [NSData dataWithContentsOfURL:newsURL];
        UIImage *image = [UIImage imageWithData:data];

        UIActivityViewController *avc = [[UIActivityViewController alloc]
                       initWithActivityItems:@[image] applicationActivities:nil];
        [avc setRestorationIdentifier:@"Activity"];
        [self.navigationController presentViewController:avc animated:YES completion:nil];
        NSLog(@"file");

    } else {
        ARSafariActivity *safariActivity = [[ARSafariActivity alloc] init];
        UIActivityViewController *avc = [[UIActivityViewController alloc] 
                       initWithActivityItems:@[self.newsTitle, newsURL] applicationActivities:@[safariActivity]];
        [avc setRestorationIdentifier:@"Activity"];
        [self.navigationController presentViewController:avc animated:YES completion:nil];
        NSLog(@"not file");
    }



}

I am using also: [newsURL isFileURL]

But the both not working, Can anyone help?

Almudhafar
  • 887
  • 1
  • 12
  • 26

0 Answers0