WKWebView跳转 获取跳转链接url 获取标题title

这篇博客介绍了如何在WKWebView中获取页面跳转后的URL以及页面标题。通过示例代码展示了具体的实现方法。
摘要由CSDN通过智能技术生成

WKWebView跳转后的页面URL获取处理。直接贴代码。
DDBWebViewController.h

//
//  DDBWebViewController.h
//  DDBIOS
//
//  Created by liwx on 2018/3/14.
//  Copyright © 2018年 io.lwx. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface DDBWebViewController : DDBViewController
@property (nonatomic, strong) NSString *urlString;
@property (nonatomic, strong) NSString *titleName;//标题
@end

DDBWebViewController.m

//
//  DDBWebViewController.m
//  DDBIOS
//
//  Created by liwx on 2018/3/14.
//  Copyright © 2018年 io.lwx. All rights reserved.
//

#import "DDBWebViewController.h"
#import <WebKit/WebKit.h>

@interface DDBWebViewController ()<WKUIDelegate,WKNavigationDelegate>

@property (weak, nonatomic)WKWebView *webView;

@property (nonatomic, strong) NSString *originUrlString;//原始URL


@end

@implementation DDBWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    WKWebView *web = [[WKWebView alloc]  initWithFrame:self.view.bounds];
    [self.view addSubview:web];
    [web mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    type
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值