【发布时间】:2020-06-10 19:42:41
【问题描述】:
我有一个带有 web 视图的 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
【问题讨论】:
-
不需要自定义渲染器来解决这个问题。您的链接器设置为什么?您是否使用任何可能引用 UIWebView 的第三方库或 nuget 包?
-
我的链接器设置是 Link Sdk only
-
另外,如果您要更新现有应用,Apple 只会警告您,您仍然可以在 2020 年 12 月之前发布。
-
不,我没有更新,我正在发布一个新应用。它正在从 appstoreconnect 中删除
-
尝试链接所有,同时检查 ipa 文件上的 grep 以查看导致问题的原因
标签: xamarin xamarin.forms xamarin.ios