2012-12-17 35 views

回答

2

我從monotouch-bindings存儲庫中獲得AdMob bindings的一些問題。但後來我切換到AlexTouch.GoogleAdMobAds綁定,他們工作得很好。您可以在Github上的README中找到使用AlexTouch.GoogleAdMobAds的示例。這很簡單,但如果你需要一些幫助 - 隨時提出更詳細的問題。

+0

非常感謝您,我使用了AlexTouch.GoogleAdMobAds,我將在稍後粘貼我的代碼。 – user1908944

+0

很高興我的綁定爲你們倆工作:) – dalexsoto

+0

謝謝你。 XD – user1908944

0
 // code for admob "using AlexTouch.GoogleAdMobAds" 
     UIViewController vc = new UIViewController(); 
     UIViewController controller = UIApplication.SharedApplication.Windows [0].RootViewController; 

     var ad = new GADBannerView (GADAdSizeCons.SmartBannerLandscape, new PointF (0, 0)) 
     { 
      AdUnitID = "ADMOB_ID", 
      RootViewController = vc 
     }; 
     ad.Hidden = false; 

     ad.DidReceiveAd += delegate { 
      ad.Hidden = false; 
      ad.Frame = new System.Drawing.RectangleF (0, (int) 0, (int) (ad.Bounds.Width), (int) (ad.Bounds.Height)); 
      Console.WriteLine ("AD Received"); 
     }; 

     ad.DidFailToReceiveAdWithError += delegate(object sender, GADBannerViewDidFailWithErrorEventArgs e) { 
      ad.Hidden = true; 
      Console.WriteLine (e.Error); 

     }; 

     ad.WillPresentScreen += delegate { 
      Console.WriteLine ("showing new screen"); 
     }; 

     ad.WillLeaveApplication += delegate { 
      Console.WriteLine ("I will leave application"); 
     }; 

     ad.WillDismissScreen += delegate { 
      Console.WriteLine ("Dismissing opened screen"); 
     }; 
     ad.UserInteractionEnabled = true; 

     vc.View.AddSubview(ad); 
     vc.View.Frame = new System.Drawing.RectangleF(0f, 0f, (int)(ad.Bounds.Width), (int)(ad.Bounds.Height)); 
     controller.View.AddSubview(vc.View); 

     Task.Factory.StartNew(() => { 
      while (true) 
      { 
       Console.WriteLine("Requesting Ad"); 
       InvokeOnMainThread (delegate { 
        GADRequest r = new GADRequest(); 

        ad.LoadRequest(r); 
       }); 
       System.Threading.Thread.Sleep(30000); 
      } 
     });