xamarin - Xamarin 表单 ios 应用程序由于已弃用的 API 使用 UIWebView 而被拒绝
问题描述
我有一个带有 webview 的 xamarin.forms 应用程序。每当我尝试将应用程序发布到苹果应用商店时,我都会收到Deprecated API Usage UIWebView
警告并且我的应用程序被拒绝。我在https://github.com/xamarin/Xamarin.Forms/issues/7323中看到了这个问题。但我无法解决我的问题。我用这个渲染替换了 webView。
public class MyWebView : WebView
{
public static readonly BindableProperty UrlProperty = BindableProperty.Create(
propertyName: "Url",
returnType: typeof(string),
declaringType: typeof(MyWebView),
defaultValue: default(string));
public string Url
{
get { return (string)GetValue(UrlProperty); }
set { SetValue(UrlProperty, value); }
}
}
在 ios 部分
[assembly: ExportRenderer(typeof(MyWebView), typeof(MyWebViewRenderer))]
namespace WKWebViewDemo.iOS
{
public class MyWebViewRenderer : ViewRenderer<MyWebView, WKWebView>
{
WKWebView _wkWebView;
protected override void OnElementChanged(ElementChangedEventArgs<MyWebView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
var config = new WKWebViewConfiguration();
_wkWebView = new WKWebView(Frame, config);
SetNativeControl(_wkWebView);
}
if (e.NewElement != null)
{
Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Url)));
}
}
}
}
我还添加了 --optimize=experimental-xforms-product-type作为附加的 mtouch 参数并发布了应用程序。还是被拒绝了。如何解决这个问题?任何帮助表示赞赏。
我的 xamarin.forms 版本:4.6.0.847
xamarin.ios 版本:13.16.0.13
解决方案
推荐阅读
- java - 使用 git 子模块代码为项目编写测试时出现“找不到包”
- html - 第三个 div 是从哪里来的?
- c# - Physics.BoxCast 来自 2D 相机屏幕空间
- php - Symfony 5 中的 Doctrine Gedmo-Extension (Timestampable, Softdeletable ...) 有替代品吗?
- node.js - mongodb在ejs文件中显示搜索到的文档数据
- flutter - 如何在 Dart/Flutter 中将数字从 20,95 转换为 20.95?
- apache-kafka - 错过了向外界开放卡夫卡的一步
- python - 是否有 Python 包可以从 4D numpy 数组创建 3D 动画?
- python - 带有 if else 条件 pandas 的数据透视表
- go - 在服务器重新启动 mqtt 服务不工作