问题描述
在我的应用中,我想使用googleAnalytics.要使用它,我必须扩展GAITrackedViewController,但是问题是我已经扩展了GLKViewController,因为我的视图有一个openGL应用程序.这样可以扩展两个视图控制器的属性吗?
in my app I want to use googleAnalytics. To use it I have to extend GAITrackedViewController but the problem is I already extend GLKViewController because my view has an openGL application. So is it possible to extend the properties of both view controllers?
推荐答案
对于类似的情况,我只是创建了UIViewController的子类(在您的情况下为GLKViewController).该子类负责视图的跟踪.所有特定"的ViewController都扩展了该自定义UIViewController,而不是默认的.
For a similar case, I've simply created a subclass of UIViewController (GLKViewController in your case). That subclass handles the tracking of the view. All "specific" ViewControllers extend that custom UIViewController, instead of the default one.
然后,您可以例如手动跟踪视图:
Then you could, for instance, track the view manually:
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
[tracker sendView: NSStringFromClass(self.class)];
这篇关于iPhone开发:是否可以扩展多个viewControllers?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!