ios - 在 WKWebview 中打开 URL
问题描述
我正在尝试在 WKWebview 中打开以下 URL,
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 值
解决方案
那可能是因为您的 URL 无效并且包含无效字符。您应该确保 url 已正确编码。
推荐阅读
- ios - UISearchBar 文本未更新文件名列表
- c - 在 c 中使用指针进行字符串输入会给我一个函数中的分段错误。相同的代码块适用于另一个功能?
- scala - Spark Scala 中类型 DataSet[Row] 和 sql.DataFrame 之间的区别
- servicestack - 使用 Http Utils 将文件作为多部分形式编码的 URL
- c++ - 确保 g++ 不会使用较新版本的 C++ 中添加的功能来编译程序
- angular - 在 connectionStrings 标记中,将执行 Angular 脚本的服务器名称写为数据源并保存
- javascript - ReactJs自定义提交按钮组件不起作用
- php - Laravel 中的电子邮件附件
- flutter - 当应用程序尝试在颤动中获取用户位置时如何添加 CircularProgressIndicator
- urlencode - 是否可以使用 apache 的 URIBuilder 设置带百分号的参数?