Reputation: 767
Xamarin.iOS. Appodeal. Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[APDImage imageUrl]: unrecognized selector sent to instance 0x280002420
class NativeAdDelegate : APDNativeAdLoaderDelegate
{
NativeAdView _nativeAdView;
public NativeAdDelegate(NativeAdView nativeAdView) =>
_nativeAdView = nativeAdView;
public override void NativeAdLoader(APDNativeAdLoader loader, NSError error) =>
Console.WriteLine("APDNativeAd DidFailToLoadWithError");
public override void NativeAdLoader(APDNativeAdLoader loader, NSArray nativeAds) =>
_nativeAdView.DidLoad(nativeAds.GetItem<APDNativeAd>(0));
}
In
nativeAds.GetItem(0)
I have title and descriptionText, but I haven't images. I get exception in nativeAds.GetItem(0).IconImage.ImageUrl.
Upvotes: 0
Views: 130
Reputation: 767
APDImage * mainImage - Bitmap of an image. An ad object contains both icon and image. It’s mandatory to use at least one of these elements.
Deprecated method.
For more details you can refer here.
public override void NativeAdLoader(APDNativeAdLoader loader, NSArray nativeAds)
{
_nativeAdView.DidLoad(nativeAds.GetItem<APDNativeAd>(0));
}
public void DidLoad(APDNativeAd nativeAd)
{
this.nativeAd = nativeAd;
UIView view = new UIView();
view.Frame = new System.Drawing.Rectangle(10, 30, 200, 200);
view.BackgroundColor = UIColor.FromRGB(96, 36, 36);
View.AddSubview(view);
this.nativeAd.AttachToView(view, UIApplication.SharedApplication.Windows[0].RootViewController);
this.myMediaView.SetNativeAd(this.nativeAd, this);
View.AddSubview(this.myMediaView);
}
Upvotes: 0
Reputation: 18861
The images is required.Otherwise the property ImageUrl
will return a null value ,which will cause the issue.
public override void DidLoadNativeAds(APDNativeAdLoader loader, APDNativeAd[] nativeAds)
{
_nativeAdView.DidLoad(nativeAds[0]);
}
For more details you can refer here.
Upvotes: 0