I want to add google analytics to my application, I followed up the instructions in this link https://developers.google.com/analytics/devguides/collection/ios/v3/#screen-tracking
I did all the instructions, my question is in the last step when I want to measure with a view controller, my view controller .h is :
#interface RootViewController : UIViewController<SectionHeaderViewDelegate, UITableViewDelegate,UIAlertViewDelegate>
in the instructions given in the link above, they said that we have to import #import "GAITrackedViewController.h" and we have to update the header like :
#interface RootViewController : GAITrackedViewController
#end
my question is shall I update the UIViewController from #interface RootViewController : UIViewController<SectionHeaderViewDelegate, UITableViewDelegate,UIAlertViewDelegate>
to
#interface RootViewController : GAITrackedViewController<SectionHeaderViewDelegate, UITableViewDelegate,UIAlertViewDelegate> ????
please help!
Many thanks.
Yes.
You need to change the inheritance from plain UIViewController to the Google tracked view controller and you need to keep all of your protocol information as well (the things in <>)
Related
I'm making an app that will use PubNub for a group chat part of the app. I turned on Playback on my app and I completed the tutorial for setting up the code. I'm confused though, because all the code was in the AppDelegate, and I have my chat view controller as part of my storyboard. My question is, what setup code do I have to do in my view controller so I can get all the past 100 messages using the historyForChannel:start:end:limit:withCompletion: method. Would I have to make a new instance of the PubNub client? That doesn't make sense since the user will be switching view controllers and It should be stored in a long life property.
What setup code do I have to do in my view controllers to get the past messages? (To be loaded into a very elaborate tableview setup)
So I figured out a working solution. First, you have to make the PubNub client property public by defining it in the AppDelegate.h file, not the .m implementation.
// AppDelegate.h
#import <UIKit/UIKit.h>
#import <PubNub/PubNub.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate, PNObjectEventListener>
#property (strong, nonatomic) UIWindow *window;
// Stores reference on PubNub client to make sure what it won't be released.
#property (nonatomic) PubNub *pnClient;
#end
And don't forget to delete from the AppDelegate.m
#import "AppDelegate.h"
#interface AppDelegate ()
/*
// Stores reference on PubNub client to make sure what it won't be released.
#property (nonatomic) PubNub *pnClient;
*/ // Delete from here
#end
#implementation AppDelegate
If you want to do notifications and such, keep the AppDelegate as a listener to the [self.pnClient] property. If not, just delete <PNObjectEventListener> from the AppDelegate.h and [self.pnClient addListener:self]; from your AppDelegate.m. If you prefer to keep it, just don't delete that stuff.
Now, #import your AppDelegate in your ChatViewController.h or the .m of you prefer. Then, make your .h conform to the <PNObjectEventListener> delegate. The, before you forget, add another client in your .h or .m to store the property of your PubNub client in your AppDelegate. :
// Stores reference on PubNub client to make sure what it won't be released.
#property (nonatomic) PubNub *pnClient;
Next, in your viewDidLoad method, add:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.pnClient = appDelegate.pnClient;
[self.pnClient addListener:self];
This code first grabs the AppDelegate of your app, (so there are no shared instance or singleton things involved). Then, It sets the pnClient of your app delegate to your "temporary" client in your view controller. (See why we moved the AppDelegate's client to the .h?) And lastly, it adds self as a listener, so you can do stuff in your view controller.
Thats all there is to it!
I would suggest using your chat controller to populate a UITableView or something else, and the AppDelegate for handling notifications.
New to iOS development and I have a tabbed app with 4 tabs. I have an iAd showing on one tab and I don't want to regurgetate the code on every view controller and I know this is not the correct way to implement anyway. I have looked at the Apple code here and I'm struggling to be honest.
https://developer.apple.com/library/ios/samplecode/iAdSuite/Introduction/Intro.html
I have included the BannerViewController.m and BannerViewController.h in my application but I'm not fully sure how to get it to run the ad on each view controller.
Yours confused
JKX
Just grab a reference of UIWindow in any of your ViewController Class
Go to .m of your ViewController
#import "AppDelegate.h"
#interface ViewController ()
{
//make object of AppDelegate
AppDelegate *appDelegate;
}
Now in your viewDidLoad or ViewDidAppear grab the reference of window.
appDelegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
[appDelegate.window addSubview:yourBannerView];
TLDR
Properties are not showing on a UIViewController that I was able to access when working on this project yesterday. This is not as simple as how do I set a property on a VC? I can not see the properties of the VC.
The Situation
A custom UIViewController (A) pushes to a second UIViewController (B), pushes to a third UIViewController (C)
//programmatically calling a push to the next view in A to B to C, example code from B to C.
EnterFinalHRViewController * finalHeartRate = [self.storyboard instantiateViewControllerWithIdentifier:#"EnterFinalHeartRateController"];
finalHeartRate.lanes = _lanes;
[self.navigationController pushViewController:finalHeartRate animated:YES];
The NSMutableArray, lanes, gets passed along twice. Not a problem.
When I arrive in VC(C) the debugger reads:
A self = (EnterFinalHRViewController *) #"0 objects" 0x15da40c0
V [0]
I have a header file in VC(C) that reads
#import <UIKit/UIKit.h>
#import "SwimTimingViewController.h"
#import "Lane.h"
#interface EnterFinalHRViewController : UIViewController <UICollectionViewDelegate, UICollectionViewDataSource, UIPickerViewDataSource, UIPickerViewDelegate>
#property (nonatomic, strong) NSMutableArray *lanes;
#end
For Clarity
Lanes is just an example of one property that is passed along.
This is not just trying to set and access a property of a VC across a segue
I've looked everywhere I can, any more links would be appreciated as well.
The Question
Why can't I see any properties of self in the final UIViewController in the debugger, how would one fix it, and or any useful debugging tips.
My Theory
Since upgrading to a new version of xcode, last night, something broke / xcode bug, and I don't know what that is. I am now using Xcode Version 6.1 (6A1052d). I am testing using my iPhone 5c running ios7. (I will be upgrading as soon as everything works 100% in ios7).
Quick shout out to thank all the contributors here at SO and beyond. The help is alway very warmly welcomed.
I am following a very easy tutorial "My first iOS app" by apple on xcode 4.2 sdkiOS5.
According to the tutorial, I am supposed to ctrl-drag a button, a text field and a label into the implementation file. myviewcontroller.m (not the .h)
According to this tutorial and its images. in this myviewcontroller.m I am supposed to see
#import "HelloWorldViewController.h"
#interface HelloWorldViewController{}
#end
#implementation HelloWorldViewController
...
and supposed to drop from the view between the #interface and the #end.
The thing is that, from what I see in xcode, the #interface thing is not in myviewcontroller.m but in myviewcontroller.h
in myviewcontroller.m I can only see this:
#import "HelloWorldViewController.h"
#implementation HelloWorldViewController
- (void)didReceiveMemoryWarning
{....
When I try to drag buttons and text fields in myviewcontroller.m the popover doesn't allow me to change into "outlet", it's fixed on "action".
On the other hand, if I try to do the same in myviewcontroller.h, I can do whatever I want, the declaration corresponds to the images shown in the tutorial (that I drop between #interface ...
(here)
#end )
but when I run the simulator, the screen stays black. Obviously, there is something wrong.
If anyone can help out a little, that would be awesome.
Cheers
The main controller is a tabBarController; one of the tabs is navigationController, then in that navigationController is a UItableView with searchDisplayController.
SearchBar is in UItableView.
However, I dont' know what I have changed (I should use snapCapture next time....). My searchBar is gone.
What I mean gone is that after my compilation, I cannot find the seaerchBar in my tab. (It is okay before I am changing sth; coz I have changed a lot, I cannot load back anymore)
I have printed a log like,
[self.searchDisplayController description]
But it is NULL.
Can sbd suggest me some directions for me to check? Thanks
In each Tab you need to add only one navigation controller, inside that you need to add either viewcontroller or tableview controller or search display viewcontroller.
You need add the objects in the above way, i dont think you have added in this format, from the image you have provided, there is only one tab in that you have added 3 navigation controllers..
I found my fault it is.
Should be
#interface ThirdViewController : ***UIViewController***
NOT
#interface ThirdViewController : ***UITableViewController***
UIViewController Class Inherits from UIResponder : NSObject
UITableViewCell Class Inherits from UIView : UIResponder : NSObject
I think that is why for tableview, I cannot show the search bar. So, in my case, I hope can help others do not make any not necessary changes, like me ##
And please do use snapCap