dViewController和UITableViewContr

dViewController和UITableViewContr

本文介绍了GAITrackedViewController和UITableViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用适用于iOS v2的谷歌分析Google建议将 GAITrackedViewController 类替换为 UIViewController 的子类。我们在UITableViewController的情况下做什么?



$ b

  #importGAITrackedViewController.h

@interface AboutViewController:GAITrackedViewController


解决方案

手动屏幕跟踪



请记住,扩展GAITrackedViewController只是跟踪屏幕视图的一种方式。手动方式同样简单。


$ b

SDK v2



   - (void)viewDidAppear:(BOOL)动画
{
[super viewDidAppear:animated];

//返回您在应用中创建的同一个跟踪器代理
// defaultTracker最初在AppDelegate.m中声明
id< GAITracker> tracker = [[GAI sharedInstance] defaultTracker];

//手动屏幕跟踪
[tracker sendView:@Home Screen];
}



SDK v3



  #importGAI.h
#importGAIFields.h
#importGAIDictionaryBuilder.h



...

   - (void)viewDidAppear :(BOOL)animated 
{
[super viewDidAppear:animated];

//返回您在应用程序中创建的相同跟踪器代理
// defaultTracker最初在AppDelegate.m中声明
id tracker = [[GAI sharedInstance] defaultTracker];

//此屏幕名称值将在跟踪器上保持设置,并以
//命中发送,直到它设置为新值或为零。
[tracker set:kGAIScreenName
value:@Home Screen];

//手动屏幕跟踪
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];

$ / code>



参考





With Google Analytics for iOS v2 Google suggests subclassing their GAITrackedViewController class in place of UIViewController. What do we do in the case of UITableViewController?

source

#import "GAITrackedViewController.h"

@interface AboutViewController : GAITrackedViewController
解决方案

Manual Screen Tracking

Remember that extending GAITrackedViewController is only one way to track screen views. The manual way is just as easy.

SDK v2

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // returns the same tracker you created in your app delegate
    // defaultTracker originally declared in AppDelegate.m
    id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];

    // manual screen tracking
    [tracker sendView:@"Home Screen"];
}

SDK v3

#import "GAI.h"
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"

...

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // returns the same tracker you created in your app delegate
    // defaultTracker originally declared in AppDelegate.m
    id tracker = [[GAI sharedInstance] defaultTracker];

    // This screen name value will remain set on the tracker and sent with
    // hits until it is set to a new value or to nil.
    [tracker set:kGAIScreenName
           value:@"Home Screen"];

    // manual screen tracking
    [tracker send:[[GAIDictionaryBuilder createScreenView] build]];
}

Reference

https://developers.google.com/analytics/devguides/collection/ios/v2/screens#manualhttps://developers.google.com/analytics/devguides/collection/ios/v3/screens#manual

这篇关于GAITrackedViewController和UITableViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:02