首页 > 解决方案 > 在 WKWebview 中打开 URL

问题描述

我正在尝试在 WKWebview 中打开以下 URL,

https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/mynameisanthony@gmail.com?secret=B6S2LGJTQHIDKIMU&issuer=someapp+Auth

        strQRImage =  @"https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/mynameisanthony@gmail.com?secret=B6S2LGJTQHIDKIMU&issuer=someapp+Auth";
        NSURL *url = [NSURL URLWithString:strQRImage];
        [webview loadRequest:[NSURLRequest requestWithURL:url]];

当我运行此代码时,它在 url 中给出 nil 值

标签: iosobjective-cwkwebviewurlencode

解决方案


那可能是因为您的 URL 无效并且包含无效字符。您应该确保 url 已正确编码。


推荐阅读