Depois de colocar uma WebKit View no StoryBoard e arrastar o Outlet para o código utilize o seguinte código:
ViewController.h
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
@interface ViewController : UIViewController <WKNavigationDelegate>
@property (weak, nonatomic) IBOutlet WKWebView *webView;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.webView.navigationDelegate = self;
//URL do site que deseja iniciar webView
NSString * mURL = @"https://www.google.com.br";
NSString * webStringURL = [mURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
NSURL* url = [NSURL URLWithString:webStringURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_webView loadRequest: requestObj];
}
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
if(navigationAction.navigationType == WKNavigationTypeLinkActivated) {
// Aqui você recebe a URL atual
NSLog(@"%@", navigationAction.request.URL);
}
decisionHandler(WKNavigationActionPolicyAllow);
}
@end