简体   繁体   English

将Google Mobile Analytics与MVVMCross集成

[英]Integrating Google Mobile Analytics with MVVMCross

The new Google Analytics SDK introduces a new subclass to UIViewController from which you have to inherit: GAITrackedViewController . 新的Google Analytics(分析)SDK向UIViewController引入了一个新的子类,您必须继承该子类: GAITrackedViewController

More info here: https://developers.google.com/analytics/devguides/collection/ios/v2/screens 此处提供更多信息: https : //developers.google.com/analytics/devguides/collection/ios/v2/screens

This obviously clashes with MvxBindingTouchViewController , as you can only inherit from one class in C#. 显然,这与MvxBindingTouchViewController冲突,因为您只能从C#中的一个类继承。

What's the recommended way in getting this working? 建议使用哪种方法来使它正常工作?

MvvmCross's MvxTouchViewController's is special... MvvmCross的MvxTouchViewController是特殊的...

MvvmCross's MvxBindingTouchViewController is even more special... MvvmCross的MvxBindingTouchViewController更加特别...

But these are only special in that they inherit from standard UIViewControllers (UIVIewController, UITableViewController, UITabBarController, etc) and then they add functionality for: 但是这些功能的特殊之处在于它们继承自标准UIViewControllers(UIVIewController,UITableViewController,UITabBarController等),然后为以下功能添加功能:

  • ViewModel construction and the ViewModel property at the Cirrious.MvvmCross layer Cirrious.MvvmCross层的ViewModel构造和ViewModel属性
  • construction and storage of Bindings at the Cirrious.MvvmCross.Binding layer Cirrious.MvvmCross.Binding层的绑定的构造和存储

Take a look at some examples: 看一些例子:

In these you can hopefully see this involves a fair amount of cut and paste of code - although we do try to minimise it using extension methods. 在这些文章中,您可以希望看到其中涉及大量的剪切和粘贴代码-尽管我们确实尝试使用扩展方法将其最小化。 (If C# had multiple inheritance or mixins, we wouldn't need to do that - I'd love to have Mixins... but don't want multiple inhertitance ever!) (如果C#具有多个继承或mixins,我们就不需要这样做-我很想拥有Mixins ...但是永远都不想继承!)

So.... if you want to add your own MvxXXXXXBindingViewController, then: 所以...如果您要添加自己的MvxXXXXXBindingViewController,则:

  1. take your base XXXXX class, 参加基础XXXXX课程,
  2. inherit from it and add 'the stuff' to make an MvxXXXXViewController, 从中继承并添加“内容”以制作MvxXXXXViewController,
  3. then take your MvxXXXXXViewController and inherit from it again to make your MvxBindingXXXXXViewController 然后使用您的MvxXXXXXViewController并再次继承它,以使您的MvxBindingXXXXXViewController
  4. publish to your blog and to a new GitHub repo so everyone else can piggyback off your hard work 发布到您的博客和新的GitHub存储库中,以便其他所有人都可以支持您的辛苦工作
  5. job done 任务完成

Advanced notes: 高级说明:

  • If you want to see the same thing in Droid, see Insert a Monogame view inside MvvmCross monodroid Activity 如果要在Droid中看到相同的内容,请参见在MvvmCross monodroid活动中插入Monogame视图

  • The TabBarController is also interesting - it's got some additional methods TabBarController也很有趣-它有一些其他方法

  • At some point 'soon' (first half of this year) we will create VeeThree and this will switch the MvxViewController's to a non generic format - this is because MonoTouch now recommends against using Generics on iOS base classes - Rolf says it's safe most of the time, but when it causes bugs they are 'heisenbugs'. 在“很快”(今年上半年)的某个时候,我们将创建VeeThree,这会将MvxViewController切换为非通用格式-这是因为MonoTouch现在建议不要在iOS基类上使用泛型-Rolf表示大多数情况下都是安全的时间,但是当它导致错误时,它们就是“ heisenbugs”。

  • There is also some dead old-iOS code in the current classes (ViewDidUnload) - this code will be culled in VeeThree too. 当前类(ViewDidUnload)中也有一些旧的iOS死代码-此代码也将在VeeThree中剔除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM