Created
October 27, 2014 14:22
-
-
Save ShingoFukuyama/28daea8da815550c29d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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