SFSafariViewController 是 iOS 9.0 出现的
可以不用跳出app直接在app内打开同Safari相似浏览效果的网页,其次玩的溜的同学可以保存数据到系统替代UUID等一些功能操作,简单使用如下:
#import <SafariServices/SafariServices.h>
<SFSafariViewControllerDelegate>
- (IBAction)action:(id)sender {
NSURL *url = [NSURL URLWithString:@"https://www.baidu.com"];
SFSafariViewController *safariVC = [[SFSafariViewController alloc] initWithURL:url];
safariVC.delegate = self;
// self.navigationController.navigationBarHidden = YES;
// [self.navigationController pushViewController:safariVC animated:YES];
// 建议
[self presentViewController:safariVC animated:YES completion:nil];
}
加载完成
- (void)safariViewController:(SFSafariViewController *)controller didCompleteInitialLoad:(BOOL)didLoadSuccessfully {
}
点击左上角的done
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
}