Skip to content

Instantly share code, notes, and snippets.

@andrassomogyi
Created September 25, 2015 09:43
Show Gist options
  • Save andrassomogyi/1528c4291a4cb5b51de5 to your computer and use it in GitHub Desktop.
Save andrassomogyi/1528c4291a4cb5b51de5 to your computer and use it in GitHub Desktop.
SFSafariViewController Objective-C example
#import <UIKit/UIKit.h>
@import SafariServices;
@interface AViewController : UIViewController
//
// ...
//
@end
#import "AViewController.h"
@interface AViewController () <SFSafariViewControllerDelegate>
@end
@implementation AViewController
//
// ...
//
- (void)displaySafari {
SFSafariViewController *safariVC = [[SFSafariViewController alloc]initWithURL:[NSURL URLWithString:@"http://developer.apple.com"] entersReaderIfAvailable:NO];
safariVC.delegate = self;
[self presentViewController:safariVC animated:NO completion:nil];
}
#pragma mark - SFSafariViewController delegate methods
-(void)safariViewController:(SFSafariViewController *)controller didCompleteInitialLoad:(BOOL)didLoadSuccessfully {
// Load finished
}
-(void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
// Done button pressed
}
//
// ...
//
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment