I've just started learning iOS development for iPhone, and following a couple of examples regarding how to display a mapView with the MapKit Framework, I found that google map tiles are not displayed, I only get an empty view (grey tiles), at least in the iPhone simulator (I haven't tried on a device).
I also get this error message:
/SourceCache/GoogleMobileMaps_Sim/GoogleMobileMaps-363.1.2/googlenav/mac/Loader.mm:235
server returned error: 403
I found solutions for similar problem when developing for Android, but not for iOS. Could somebody help me with this issue? Adding the MapKit framework to the project is supposed to be enough to get this working, or maybe am I missing some extra settings that are not mentioned in the tutorials I've followed?
Thanks!
This is the simple sample code I used:
// ViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#interface ViewController : UIViewController
#property (strong, nonatomic) IBOutlet MKMapView *mapView;
#end
// ViewController.m
#import "ViewController.h"
#implementation ViewController
#synthesize mapView=_mapView;
- (void)viewDidUnload {
[super viewDidUnload];
[self setMapView:nil];
}
... more methods...
And in .xib file, I connected a MKMapView to the file's owner mapView outlet. And at this point, according to the tutorial, I am supposed to be able to see a default US map when running the simulator, but I'm always getting the error I posted before at the debug area, and map view displays only the grey empty grid.
I had the same problem - my UIMapView was only showing the grid, but not the actual map. I quit the simulator and then launched the project again - now it showed the map! It seems like iOS simulator does loses the connection sometimes, even though you might be connected on your computer.
Thank you all for your input!
Have you set the delegate to files owner(self)?
Also have you included mapkit framework and the related header files?
For whatever reason, my iOS simulator sometimes just loses connection to the internet (my computer has connection, but the simulator doesn't recognize it). Once I quit and relaunched my simulator, my maps started showing.
The iOS simulator comes with the official maps app included. Open that and verify that it can get tiles, it could be a network issue. Without any code, outlets, delegates or anything the map should show map data.
An empty map view (grey tiles) as you've described I have seen on the iPhone simulator and a device when trying to specify a map region (see code below for example), however the user has not granted access to their location in app settings. Removing this piece of code when running on the simulator resolved the issue.
MKCoordinateRegion mapRegion;
mapRegion.center = self.mapView.userLocation.coordinate;
mapRegion.span.latitudeDelta = 0.02;
mapRegion.span.longitudeDelta = 0.02;
[self.mapView setRegion:mapRegion animated: YES];
In case anyone looking for the solution. Network issue is solely responsible for this issue. Make sure your simulator has network connection and if it is able to load default apple map, you're good to go.
This issue is a little bit tricky because it involves lots of cases, but for me, it was not loading because of the network monitoring application, eg. Charles, make sure that you have an internet connection and it's unmonitored
I solved this problem by connecting to WIFI with my phone. I didn't have a SIM card installed in my phone, so it just showed the tiles. Just make sure you have network connection.
Related
I'm having problems taking the first few steps with MapBox iOS SDK (1.4.1).
I've started with the suggested code over here: https://www.mapbox.com/mapbox-ios-sdk/examples/
- (void)viewDidLoad {
[super viewDidLoad];
self.mapBoxView.tileSource = [[RMMapboxSource alloc] initWithMapID:#"my_map_id" enablingDataOnMapView:_mapBoxView];
self.mapBoxView.userTrackingMode = RMUserTrackingModeNone;
CLLocationCoordinate2D centerLocation;
centerLocation.latitude = NRMapStartLatitude;
centerLocation.longitude = NRMapStartLongitude;
[self.mapBoxView setCenterCoordinate:centerLocation];
[self.mapBoxView setZoom:7 animated:YES];
}
No matter what I do the map starts at a location in Washington D.C. but I've set the center coordinate to be somewhere in Europe.
The same with the zoom. No matter what value I try it has no effect on the map.
There's something with the NSLog output that confuses me. At startup it says:
Using watermarked example map ID examples.map-z2effxa8. Please go to
https://mapbox.com and create your own map style.
I was assuming that this is something that I already did by registering for a free account there and starting with my first project.
Added the tilesource 'My First Map' to the container
Origin is calculated at: 120.786199, -85.000000 Map initialised. tileSource:RMMapboxSource:
Mapbox iOS Example, zooms 0-19, no interactivity, minZoom:2.000000, maxZoom:18.000000,
zoom:18.000000 at {-77.032458,38.913175}
Apparently the sample project in the iOS SDK is loaded and ignoring everything else I try to configure.
So, how do I configure the map so I can interact with the API. What am I missing?
Any kind of help is highly appreciated. Thank you!
OK, whoever is struggling with that. The trick is to set the zoom BEFORE you set the center coordinate..
..for whatever reason.
I have an app where I am trying to track screens with Google analytics.
I have set everything up in the delegate, and tried to automatically track three screens. Out of the three screens, only 1 of them is automatically tracking, the other two I had to track manually. I do not understand why this is the case, but I've tried looking for solutions and answers but none have come up.
The one class where the automatic screen tracking worked in in my SettingsViewController
in SettingsViewController.h I import "GAITrackedViewController.h"
and in SettingsViewController.m I do the following:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.screenName = #"Settings";//GOOGLE ANALYTICS WAS IN ViewWillDisappear
//rest of code
}
This works because in Google Analytics, I can see all the times that I've seen this view and I have all the tracking data necessary.
It gets annoying in my other two classes where I tried the EXACT SAME THING and did no get the same results.
In both my FriendView and HomeView I tried doing the automatic screen tracking, but that did not work in either view, so I tried implementing the manual screen tracking.
In both my HomeView and FriendView I do the following:
#import "GAI.h"
#import "GAIFields.h"
#import "GAIDictionaryBuilder.h"
#import "GAITrackedViewController.h" //Import from when I tried automatic screen tracking
and then I do
-(void)viewDidAppear:(BOOL)animated{
//self.screenName = #"Friends";//GOOGLE ANALYTICS
[super viewWillAppear:animated];
id tracker = [[GAI sharedInstance] defaultTracker];
[tracker set:kGAIScreenName
value:#"Friends"];
[tracker send:[[GAIDictionaryBuilder createAppView] build]];
}
The manual tracking works better because I can see it under real time screen tracking. But for some reason I still cannot see FriendView or HomeView screen tracking under Behavior/ Screens in Google Analytics. The only data I have is from the SettingsView.
I would much rather use the automatic screen tracking because it is less code, but I have tried this solution and various others to try and get automatic screen tracking to work, and to be visible in Google analytics but it just does not.
To be clear, in both cases, the data does not show up in my screen tracking data. Only my settingsView data is visible and sending. The only difference is that when I do the manual screen tracking I can see the data come in real time, but it still does not show up in the general screen data view.
I am using v 3.0.7 in my app.
Thank you in advance for any solutions.
I also tried all different ways to track screen views in GA (manual vs auto, createAppView vs createScreenView, in viewDidAppear vs in viewWillAppear, etc) and for a long time I thought they weren't working. I also turned on verbose debug mode and everything seems correct (returning 200, screen name being logged as I expected). Later I realized that they were actually recorded, I was just looking at the wrong place in GA website.
They are not in Site Content/All Pages, and they are not in Behavior Flow, or Events/Pages. But if you select anything like an event, and select "Screen Name" as a primary or secondary dimension, then you can see all of them. Or you can create a customized report and directly display screen name.
I'm surprise that screen views are so hard to find in the GA web interface. I hope that Google can make a change to treat the screen views like web's pages, and be able to see a flow chart of the transitions.
EDIT:
Then I realized that it's because I'm posting all the data into a view that's configured for website, not for mobile app. (Initially we wanted to track app and web in the same view.) When I created a new GA view for mobile only, everything makes sense now.
Everything is perfectly fine only the section in which you are searching the screen is wrong. So go to > Reporting > Real Time > Screens to view you screen or else try to search SCREEN in the search box and that will give you various options then try them one by one to get the correct option.
To automatically measure views in your app, have your view controllers extend GAITrackedViewController. Set a property called screenName with the name of the screen that you want to appear in your reporting.
For example, suppose you have a “Home Screen” view that you want to measure with a view controller header that looks like this:
#interface HomeViewController : UIViewController
You would update this header to:
#import "GAITrackedViewController.h"
#interface HomeViewController : GAITrackedViewController
You must also provide the view name to be used in your Google Analytics reports. A good place to put this is the view controller's initializer method, if you have one, or the viewWillAppear: method:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.screenName = #"Home Screen";
}
For more information Please go through this link Google Analytics
the whole code is look like this
I dont know why the iPhone app crashes and it gives lldb error only.I tried to add the exception break point too.
.h file:
IBOutlet UITextField *etCountry;
.m file:
etCountry.delegate=self;///
This is the line i am getting the crash.Please give me the solution for me
Make sure your textfield has connection like this below images,
This is how
self.etCountry.delegate=self;
And add
#interface YourViewController ()<UITextFieldDelegate>
#end
You may check other threads, and their stack. My guess is that there is everything is fine with text field. Seemingly there seems a network call also in the background, maybe a callback block is not in the right format. That caused similar "hidden" crashes to me.
I am updating my old app to iOS7. In that app i am displaying line over map using MKPolyline.
its working fine in iOS6 and Xcode 4.6 but doesnt work in my new xcode and displayed error on the codes of MKPolyline.
Is apple has change MapKit Framework. what should i have to update?
On the MKPolyline codes display this error
Unknown type name 'MKPolyline'
But if i Control-Click the MKPolyline than it will take me to the MapKit class.
First of all i think this is the problem with the #import code. You said that this is an old app. please show us the #import code for mapkit framework.
If it like this:
#import "MapKit/MKMapView.h"
than change it to this:
#import <MapKit/MapKit.h>
I think this will solve the unknown class error. if still its display error than use MKGeodesicPolyline instead of MKPolyline. You can find nice explanation here.
Hope it help.
I know that Popover controllers are for use exclusively on iPad devices, but on below question there is a comment in which user has mentioned about category, code is as below,
UIPopoverController for iphone not working?
// UIPopoverController+iPhone.h file
#interface UIPopoverController (iPhone)
+ (BOOL)_popoversDisabled;
#end
// UIPopoverController+iPhone.m file
#implementation UIPopoverController (iPhone)
+ (BOOL)_popoversDisabled {
return NO;
}
#end
Is this right way?
Will Apple approve this?,
My iPad application is already done, now I am making it universal application, so instead of using any custom popover I want to add this category so that it will solve my issue and will reduce development efforts.
This is very hacky way, and you'll be taking a big risk putting it on the AppStore. Sure someone may have put a version in the store where they overlooked this, but it can break any moment and Apple may decide to remove his app.
Have you tested popovers on iPhone? Will you test in iOS7.1? Will it work exactly the same on iOS7.2 or iOS 7.3?
A far better solution would be to take an open source implementation of popovers and use that for iPhone (or both).
I have live app with with popover in iPhone.
Just You have to create interface for popover
NSObject+UIPopover_Iphone.h
#import <Foundation/Foundation.h>
#interface UIPopoverController (overrides)
+(BOOL)_popoversDisabled;
#end
NSObject+UIPopover_Iphone.m
#import "NSObject+UIPopover_Iphone.h"
#implementation UIPopoverController (overrides)
+(BOOL)_popoversDisabled
{
return NO;
}
#end
and now just import NSObject+UIPopover_Iphone.h in your Viewcontroller.h
Edit
For iOS 8 you can use
WYPopoverController.