ios Facebook将FBNativeAdView添加为Subview

前端之家收集整理的这篇文章主要介绍了ios Facebook将FBNativeAdView添加为Subview前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用FBNativeAdView的预建视图(不想自定义FBNative Ad).如 link中给出的那样

The FBNativeAdView creates prebuilt native ad template views and
manages native ads.

我在Facebook SDK中给出了Changed NativeAdSample示例.并将FBNativeAdView添加为mainView(adUIView)的子视图.

-(void) nativeAdDidLoad: (FBNativeAd * ) nativeAd 
{
        NSLog(@"Native ad was loaded,constructing native UI...");

        if (self._nativeAd) 
        {
            [self._nativeAd unregisterView];
        }

        self._nativeAd = nativeAd;

        // Here I did add
        FBNativeAdViewAttributes * attributes = [[FBNativeAdViewAttributes alloc] init];
        attributes.backgroundColor = [UIColor whiteColor];
        attributes.titleColor = [UIColor blackColor];

        FBNativeAdView * fbNativeAdView = [FBNativeAdView nativeAdViewWithNativeAd: self._nativeAd withType: FBNativeAdViewTypeGenericHeight300 withAttributes: attributes];
}

所以问题是如何添加fbNativeAdView作为ParentView的子视图,所以它应该在父视图中查看.我做了它

[self.adUIView addSubview:fbNativeAdView];

没有成功.

Native Ad Template提供了有关如何从FBNativeAd获取FBNativeAdView的信息.但是没有告诉我如何在uiview中使用FBNativeAdView.

解决方法@H_404_21@
现在它使用FBNativeAdView中的添加框架作为
fbNativeAdView.frame = CGRectMake(0,320,120);

此外,现在Native Ad Template提供了有关如何在uiview中使用FBNativeAdView的信息.

The ad template can be customized by changing the values of its
elements:

06001

原文链接:https://www.f2er.com/iOS/333491.html

猜你在找的iOS相关文章