Xamarin forms ios应用程序由于废弃的API使用UIWebView而被拒绝。

问题描述 投票:0回答:1

我有一个xamarin.forms应用程序,它有一个webview。每当我尝试将应用程序发布到苹果应用商店时,我都会得到以下信息 Deprecated API Usage UIWebView 警告,我的应用程序被拒绝。我看到这个问题在 https:/github.comxamarinXamarin.Formsissues7323。. 但我无法解决我的问题。我用这个渲染替换了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

xamarin xamarin.forms xamarin.ios
1个回答
1
投票

不能把这个作为评论发布,因为我想分享一张图片。

这发生在我之前,我也设置了 --optimize=experimental-xforms-product-type 但我还是得到了这个错误。

我的问题是,我为错误的配置设置了那些额外的mtouch参数。正如你在图片中所看到的,确保你将这些值放在正确的配置和平台上! 它应该是你用于创建存档的相同组合。Visual Studio screenshot showing the iOS Project options

© www.soinside.com 2019 - 2024. All rights reserved.