Skip to content

Instantly share code, notes, and snippets.

@ShingoFukuyama
Created October 27, 2014 14:22
Show Gist options
  • Save ShingoFukuyama/28daea8da815550c29d4 to your computer and use it in GitHub Desktop.
Save ShingoFukuyama/28daea8da815550c29d4 to your computer and use it in GitHub Desktop.
#import "ViewController.h"
#import <WebKit/WebKit.h>
@interface ViewController ()
@property (nonatomic, strong) WKWebView *webView;
@property (nonatomic, strong) UIActivityViewController *activityController;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_webView = [[WKWebView alloc] initWithFrame:self.view.bounds];
NSString *urlString = @"http://www.cleanshavenapps.com/clips/";
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.view addSubview:_webView];
[_webView loadRequest:request];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSString *title = _webView.title;
title = [title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (!title || title.length == 0) title = @"Website Title";
NSURL *url = _webView.URL;
_activityController
= [[UIActivityViewController alloc] initWithActivityItems:@[title, url] // @[url] works
applicationActivities:nil];
[self presentViewController:_activityController animated:YES completion:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment