一、使用官方safri导入#import <SafariServices/SafariServices.h>
//可以当webView来使用,里面的逻辑都不需要自己去实现 SFSafariViewController *view = [[SFSafariViewController alloc] initWithURL:[NSURL URLWithString:url]]; UITabBarController *tabTar = (UITabBarController *)self.window.rootViewController; [tabTar.selectedViewController presentViewController:view animated:YES completion:nil];
二、自己添加个web控制器和下面添加toolBar(上面放的是toolBarItem)
@interface BSWebViewController ()@property (weak, nonatomic) IBOutlet UIWebView *webView;@property (weak, nonatomic) IBOutlet UIBarButtonItem *faword;@property (weak, nonatomic) IBOutlet UIBarButtonItem *goBack;@end@implementation BSWebViewController- (void)viewDidLoad { [super viewDidLoad]; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]]; self.webView.delegate = self;}- (IBAction)forward:(UIBarButtonItem *)sender { [self.webView goForward];}- (IBAction)goBack:(UIBarButtonItem *)sender { [self.webView goBack];}- (void)webViewDidFinishLoad:(UIWebView *)webView{ self.faword.enabled = webView.canGoForward; self.goBack.enabled = webView.canGoBack;}
h
上面放上的webview,下面就是toolBar