Developing a user interface on iOS environment using GoogleMaps APIv3 - iphone

I'm new to iOS development. Today, I created a new "SingleViewApplication". I added new Navigation Bars using storyboarding.
Next, I followed the tutorial https://developers.google.com/maps/documentation/ios/start to integrate Google Maps into my project.
However, after adding GoogleMaps, my Navigation Bar has disappeared. Somehow, Google Maps override the interface constructed by using storyboard.
Any suggestions, tutorials, information is kindly appreciated.
The codes are given below:
shareAppDelegate.h
#import <UIKit/UIKit.h>
#interface shareAppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
shareAppDelegate.m
//
// shareAppDelegate.m
// share
//
// Created by neva on 9/17/13.
// Copyright (c) 2013 neva. All rights reserved.
//
#import "shareAppDelegate.h"
#import <GoogleMaps/GoogleMaps.h>
#implementation shareAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[GMSServices provideAPIKey:#"AIzaSyDqbi8tp0DeUHQKASyRyJUqJbOZpMOuuig"];
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#end
ShareViewController.h
//
// shareViewController.h
// share
//
// Created by neva on 9/17/13.
// Copyright (c) 2013 neva. All rights reserved.
//
#import <UIKit/UIKit.h>
#interface shareViewController : UIViewController
#end
ShareViewController.m
//
// shareViewController.m
// share
//
// Created by neva on 9/17/13.
// Copyright (c) 2013 neva. All rights reserved.
//
#import "shareViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#interface shareViewController ()
#end
#implementation shareViewController{
GMSMapView *mapView_;
}
- (void)loadView {
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = #"Sydney";
marker.snippet = #"Australia";
marker.map = mapView_;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end

Related

Google analytics doesn't show tracking of my App

I would like to Integrate Google Analytics Tracking into my IOS APP.
I have integrated Google Analytics Library and Add It To my Application.
Here is my code snippet,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[UIApplication sharedApplication].statusBarHidden = NO;
[GAI sharedInstance].trackUncaughtExceptions = YES;
[GAI sharedInstance].dispatchInterval = 1;
[GAI sharedInstance].debug=YES;
[[GAI sharedInstance] trackerWithTrackingId:#"UA-43556575-1"];
return YES;
}
Code In my FirstViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.trackedViewName = #"Home";
....
....
}
List of Librarys which i have added, (First i have copied all this library from download folder then added to my project folder and then in Xcode i am taking reference from project folder)
GAI.h
GAITrackedViewController.h
GAITracker.h
GAITransaction.h
GAITransactionItem.h
libGoogleAnalytics.a
Almost 5 days and still stuck with same problem :(
:
Please Help ...
Thank you for reading and thanks in advance.
I think this may be one case.
Your UIViewController class must be a subclass of the GAITrackedViewController class,
#interface FirstViewController : GAITrackedViewController
And Must override these function.
-(void)viewDidLoad
{
[super viewDidLoad];
self.trackedName = #"Home";
// your code here
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// your code here
}
As viewDidLoad and viewDidAppear: are important methods.
And Remember the profile must be for mobile app.

GREE Integration endup with Errors

I integrated GREE in an iOS application(demo) and after a day long hard work the code was good enough to go, that executed properly and produced some UI response but, pity that was no worthy, check:
Also I have something in my console;
2012-12-04 09:52:22.721 GreeHelloSample[1295:1bb03] GreeJSAbstractStateCommand:name must be overloaded in subclasses.
2012-12-04 09:52:22.724 GreeHelloSample[1295:1bb03] GreeJSAsyncCommand:name must be overloaded in subclasses.
2012-12-04 09:52:22.725 GreeHelloSample[1295:1bb03] GreeJSLoadAsynchronousCommand:name must be overloaded in subclasses.
2012-12-04 09:52:22.997 GreeHelloSample[1295:1bb03] [Gree][GreePlatform.m:381] Initialized Gree Platform SDK 3.4.0 (Build release/v3.4.0_public_189)
2012-12-04 09:52:24.589 GreeHelloSample[1295:1bb03] didLogoutUser
2012-12-04 09:52:25.003 GreeHelloSample[1295:1bb03] greePlatformWillShowModalView
But I am tired and unable to track What went wrong, now? So, help me.
EDIT 1:
Here is All related code I wrote:
.h
#import <UIKit/UIKit.h>
#import "GreePlatform.h"
#import "GreePlatformSettings.h"
#define kGreeApplicationID #"XXXXX"
#define kGreeConsumerKey #"XXXXXXXXXXXX"
#define kGreeConsumerSecret #"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
#class GHSViewController;
#interface GHSAppDelegate : UIResponder <UIApplicationDelegate, GreePlatformDelegate>
#property (retain, nonatomic) UIWindow *window;
#property (retain, nonatomic) GHSViewController *viewController;
#end
.m
#import "GHSAppDelegate.h"
#import "GHSViewController.h"
#implementation GHSAppDelegate
- (void)dealloc
{
[_window release];
[_viewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[GHSViewController alloc] initWithNibName:#"GHSViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:GreeDevelopmentModeSandbox, GreeSettingDevelopmentMode, nil];
[GreePlatform initializeWithApplicationId:kGreeApplicationID
consumerKey:kGreeConsumerKey
consumerSecret:kGreeConsumerSecret
settings:settings
delegate:self];
[GreePlatform handleLaunchOptions:launchOptions application:application];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
[GreePlatform shutdown];
}
#pragma mark - GreePlatformDelegate
/**
* Sent to the receiver when Gree will show a modal view (dashboard, login dialogs,
* etc.) that will interrupt your application.
* #note It is recommended that you suspend your application logic here.
*/
-(void)greePlatformWillShowModalView:(GreePlatform*)platform{
NSLog(#"greePlatformWillShowModalView");
}
/**
* Sent to the receiver when Gree has dismissed a modal view (dashboard, login dialogs,
* etc.) that was interrupting your application.
* #note It is recommended that you resume your application logic here.
*/
-(void)greePlatformDidDismissModalView:(GreePlatform*)platform{
NSLog(#"greePlatformDidDismissModalView");
}
/**
* Sent to the receiver when your application's user logs in to the Gree Platform.
*/
-(void)greePlatform:(GreePlatform*)platform didLoginUser:(GreeUser*)localUser{
NSLog(#"didLoginUser");
}
/**
* Sent to the receiver when your application's user logs out of the Gree Platform.
*/
-(void)greePlatform:(GreePlatform*)platform didLogoutUser:(GreeUser*)localUser{
NSLog(#"didLogoutUser");
}
/**
#brief Notifies the parameter received when an application starts.
#param params Parameter received when an application starts.
*/
-(void)greePlatformParamsReceived:(NSDictionary*)params{
NSLog(#"greePlatformParamsReceived");
}
Here we go!
I have made one silly mistake to suffer this. Actually I was using Production (Gree Application) ID, for executing my application in sand box. Although Gree Provide different Sandbox ID to run Application in Sandbox environment. Rest of the things are Okay thanks to Gree framework SDK, and specially Showcase*(sample application).

Trying to make my iphone app universal. Navigation Controller keeps saying Unbalanced calls

have been trying couple of hours now to make my iphone app universal. The mission was successful but have a strange problem. The navigation controller keeps pushing things without even pushing anything. The app doesn't crash but it gives me a message in the console
nested push animation can result in corrupted navigation bar
2012-02-06 10:52:07.701 ##$%^^$[54755:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2012-02-06 10:52:07.704 !##$%^$%#[54755:207] Unbalanced calls to begin/end appearance transitions for <searchEditViewController: 0xc652150>.
and here is how i've set app the whole thing :
![navigation screen shot][1]
here is my code in the AppDelegate_iphone.h
#import <UIKit/UIKit.h>
#import "iPhoneView.h"
#import "AboutUsViewController.h"
#import "FavoritesViewController.h"
#class iPhoneView;
#interface AppDelegate_iPhone : NSObject <UIApplicationDelegate> {
UITabBarController *tabBarController;
UINavigationController *homeNavigationController;
UINavigationController *favouritesNavigationController;
AboutUsViewController *aboutUsViewController;
iPhoneView * search;
FavoritesViewController *favoritesViewController;
UIWindow *window;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet iPhoneView *search;
#property (nonatomic, retain) FavoritesViewController *favoritesViewController;
#end
and here is on my AppDelegate.m file
#import "AppDelegate_iPhone.h"
#import "iPhoneView.h"
#implementation AppDelegate_iPhone
#synthesize window,search,favoritesViewController;
#pragma mark -
#pragma mark Application lifecycle
- (void)applicationDidFinishLaunching:(UIApplication *)application
{ tabBarController = [[UITabBarController alloc] init];
homeNavigationController = [[UINavigationController alloc] init];
search = [[iPhoneView alloc] init];
[homeNavigationController pushViewController:search animated:NO];
favouritesNavigationController = [[UINavigationController alloc] init];
favoritesViewController = [[FavoritesViewController alloc]init];
[favouritesNavigationController pushViewController:favoritesViewController animated:NO];
aboutUsViewController =[[AboutUsViewController alloc] init];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:#"επικοινωνία" image:[UIImage imageNamed:#"aboutus"] tag:0];
aboutUsViewController.tabBarItem = item;
[item release];
UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:#"αγαπημένα" image:[UIImage imageNamed:#"favorites"] tag:0];
favouritesNavigationController.tabBarItem = item2;
[item2 release];
NSArray *tabBarControllerCollection = [NSArray arrayWithObjects:homeNavigationController,favouritesNavigationController,aboutUsViewController,nil];
[tabBarController setViewControllers:tabBarControllerCollection animated:NO];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[tabBarController release];
[search release];
[favoritesViewController release];
[favouritesNavigationController release];
[aboutUsViewController release];
[window release];
[super dealloc];
}
#end
OK solved had connected the button 2 times with the same action in IB. Took me 48hours to figure it out!

How to remove UINavigationViewController

I have created one navigationController in name_of_my_appAppDelegate.h...
After the use I want to remove it from the superview...
in my name_of_my_RootViewController I want to call it and remove.
How to call it?
In the NewsPadViewController, how to remove the NavigationController when I finished to use it?
#import <UIKit/UIKit.h>
#class NewsPadViewController;
#interface NewsPadAppDelegate : NSObject <UIApplicationDelegate>{
UIWindow *window;
UINavigationController *navigationController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
#end
and this is the implementation
#import "NewsPadAppDelegate.h"
#import "NewsPadViewController.h"
#implementation NewsPadAppDelegate
#synthesize window;
#synthesize navigationController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
- (void)dealloc
{
[navigationController release];
[window release];
[super dealloc];
}
#end
Check this out: UINavigationController Class Reference.
You probably want something like this:
[name_of_my_RootViewController popToRootViewControllerAnimated:YES];
Or:
[name_of_my_RootViewController.view removeFromSuperview];
Or:
for (UIView *v in self.view.subviews) {
if ([v isEqual:myView]) {
[myView removeFromSuperview];
}
}
Or:
[((NewsPadAppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController.view removeFromSuperview];
To remove the view controller you remove its view, like this:
[name_of_my_RootViewController.view removeFromSuperview];
Sounds like you should be presenting the UINavigationController modally in the first place. Set up a plain UIViewController called rootViewController and make that visible instead of the navigation controller, then call:
[rootViewController presentModalViewController:navigationController animated:YES];
And when you're done with it, hit a button on the navigation controller which calls:
[self dismissModalViewControllerAnimated:YES];
And you'll go back to the plain UIViewController where you can show the rest of your app.

How to add a custom iPhone UI element that is not an IB component?

I'm trying to create an application that uses the iPhone MapView (under Google Code). I can't figure out how to integrate this thing into my application without handwriting the entire UI, ie not using the IB at all.
How can I use the Interface builder to create all of my menus and such but add the MapView in? Do I need to edit the MapView to make it an IB component?
Thanks!
EDIT:
#pgb
Here is my code, it still just displays a blank UIView, I have connected everything up on the IB side.
//
// NewTestViewController.h
// NewTest
//
#import <UIKit/UIKit.h>
#interface NewTestViewController : UIViewController {
UIView* mapPlaceholder;
}
#property (nonatomic, retain) IBOutlet UIView* mapPlaceholder;
#end
//
// NewTestViewController.m
// NewTest
//
#import "NewTestViewController.h"
#import "MapView.h"
#implementation NewTestViewController
#synthesize mapPlaceholder;
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
MapView *mapView = [[[MapView alloc] initWithFrame:
[[UIScreen mainScreen] applicationFrame]] autorelease];
[mapPlaceholder addSubview:mapView];
}
return self;
}
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[mapPlaceholder.subviews release];
[super dealloc];
}
#end
NEVERMIND FIGURED IT OUT THANGS PBG
You can probably create the whole interface in IB, add an empty UIView as the placeholder view, and then use addSubview: to add the MapView instance to the view hierarchy.
Your placeholder view can be defined as an IBOutlet, so you can then add the MapView from your UIViewController instance.
In IB you can add a UIView and then change the type of the view to any custom UIView - I'm assuming MapView subclasses UIView just as MKMapView does...
I'm trying to create an application that uses the iPhone MapView (under Google Code).
Why not use MapKit? Surely IB comes with an MKMapView in its Library.