I just recently updated my iOS SDK to the latest release (6.0).
I used to have a couple of map views in my app, MKMapView, that were
used to show the user location.
After the update, upon setting the property
mapView.showUserLoaction = YES;
The app crashes with the following exception:
-[MKCoreLocationProvider locationManager:didUpdateToLocation:fromLocation:]: unrecognized
selector sent to instance 0x155af5f0
This happened on iPhone iOS 6.0 Simulator, not on device/simulators with previous versions of the OS.
The error can be reproduced just by setting the property. Otherwise the app run smooth.
The bug came up just after updating the SDK. Moreover, I didn't test on a iOS 6 device yet (all the test on such a device have been performed with the previous version of the SDK though, and the app didn't crash).
What could be the issue?
UPDATE: in iOS6 Device there are no issues. The problem appears just on the iOS 6 Simulator
Have you tried ?
[mapView setShowsUserLocation:YES];
if you are using a MKMapViewYou should also be using if you are doing something with the userlocation
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
}
I am using this delegate method and this is working fine for me in ios6
-(void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
{
}
Related
I have developed both iPhone & iPad application which supports for iOS 5 and iOS 6
in that application i have grabbed user current location using CLLocationManager.
when i want to stop updating receiving GPS coordinates. I have called stopUpdatingLocation
method to stop calling didUpdateToLocation method. It was woking completely fine with iOS 5 and 6 But unfortunately its not working with iOS 7.
Seems that stopUpdatingLocation method is not working .Any particular reason. ??
i had a keep a variable to monitor the life cycle of didUpdateToLocation method and stop executes it.
One thing might be possible is,
Your current location blue dot moving on your map is because you set the MKMapView's showsUserLocation to YES. It will track until you set it to NO.
Second thing,
You might be setting below thing to stop calling that method
locationManager = nil;
That does not stop monitoring, but what it does, not to refer the location manager, So now its not possible to stop monitoring.
Instead add below code & then see what happen
[locationManager stopUpdatingLocation];
locationManager=nil;
Hope it helps..
#tdevoy - Here is sample
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *location = [locations lastObject];
latitude = location.coordinate.latitude;
longtitude = location.coordinate.longitude;
//stops updating current user location update
[locationManager stopUpdatingLocation];
}
I'm able to receive location updates on all (simulators and iPad device) but my iPhone device.
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
self.locationManager.pausesLocationUpdatesAutomatically = NO;
self.locationManager.delegate = self;
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *newLocation = locations.lastObject;
NSLog(#"didUpdateLocations newLocation = %#", newLocation);
.
.
}
I receive didUpdateLocations (NSLog message) as long as app is in foreground but after I press Home button (i.e. app goes in background), I stop receiving notifications in didUpdateLocations. The 'console' doesn't show the NSLog message and thereafter even the location icon in status bar goes away within 10 seconds.
What works an what doesn't -
Appears that iOS 6 installed on my other iPhone 3gs works fine. The little location icon doesn't go away.
Test on iPad device with iOS 7 and the app keeps running in background.
All simulators (iPhone and iPad) with iOS 6 as well as iOS 7 works as expected.
When i test it on my iPhone 4 with iOS 7, the app doesn't run in background. So probably, this issue is only on iOS 7 (and even some specific iPhone devices).
I think I found the cause of this problem. The "Settings" app in iOS 7 has General > "Background App Refresh" which was turned OFF :(
As soon as I turned it "ON", my app started running in background :)
The above solution did not work for my particular case in iOS 8.X, therefore, I would like to post the solution that worked for me in hopes that it might help others.
I successfully setup silent Push Notifications which I was receiving in the Foreground, Background, and Suspended states. Once I received the PN I would need to obtain the location updates. I was able to do so while the application was in the Foreground, however, I was not able to do so while the application was in the background.
What I needed to do was add a key to the info.plist file called NSLocationAlwaysUsageDescription and give it a value. The value can be something like "Your location is needed in the background."
After adding the key I then added this code within my AppDelegate.m's application:didFinishLaunchingWithOptions: method -
// Check for iOS 8.X. Without this guard the code will crash with "unknown selector" on iOS 7.
if([[self locationManager] respondsToSelector:#selector(requestAlwaysAuthorization)])
{
[[self locationManager] requestAlwaysAuthorization];
}
Once I added these two pieces I was able to successfully obtain location updates in the background.
Thanks,
audible
I have an app with a target of iOS 5.0. Unfortunately, I no longer have any test devices with iOS 5.
I'd like to be able to use the iOS 5.0 and 5.1 simulators to do basic debugging, but for some reason, my IBActions aren't being called on these simulators.
Further info:
Xcode version is 4.5.2
All simulators are up-to-date (no pending updates/downloads available)
We do have customers who use iOS 5 and 5.1, and they don't have any issues clicking the buttons (or at least, we haven't received any reports about such from them ; )
On the iPhone 6.0 simulator, everything works as expected (pretty sure all IBActions are connected correctly)
Are these simulators just terribly buggy (is this a known issue)? Have others ran into this issue and know a fix?
It turns out that a UITapGesture on self.view was capturing the touches and NOT forwarding to the subviews... for some reason, this behavior appears to be different in iOS 6 and iOS 5 simulators... user beware...
Most Probably issue i seen that..
might be you not define your IBAction method in .h file.
might be you connect two IBAction on one UIButton TouchUpInside.
you also try uninstall app from simulatore clear xcode than might be solve your issue.
reset you simulator contain.
Check is any update of Xcode then you try to run your app then you got solution.
I am working on same configuration and i have no issue like yours..
Use UIGestureRecognizerDelegate to avoid effect of gestureRecognizer on a selectedView:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer shouldReceiveTouch:(UITouch *)touch {
UIView *selectedView = self.view;
CGPoint point = [touch locationInView:self.view.superview];
if (CGRectContainsPoint(selectedView.frame, point)) {
return NO;
}
else {
return YES;
}
}
I have to run my app using iPhone OS 4.0. but while I am running my app the CLLocationManager delegate is not getting called.
The delegate method is
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
}
I can probably help, as I've been dealing with CLLocationManager successfully on iOS4 on a 3GS device, but I need more information.
1) Did you alloc/init the CLLocationManager previously and call startUpdatingLocation? Please include that code, we may be able to help. Specifically, where/how you are setting the delegate? Also, make sure someone is retaining your delegate class so that way you're able to receive the calls. CLLocationManager will not retain the delegate.
2) Are you testing on a device, or on the Simulator? If you are testing on a device, which device?
I have an application with map and want to zoom to the current location, when it's updated.
I use -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation delegate method to know when user location was updated.
Now on simulator method is being called as it should. But when i test it on device (iphone 2g) the location is updated on map, but "didUpdateUserLocation" method is not being called at all, same for delegate method "mapViewWillStartLocatingUser".
The system asks if I allow to get my location for app and starts showing my location, but
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
NSLog(#"didUpdateUserLocation = '%#'", userLocation);
}
is never called.
Reference mentions that this delegate method is available since iOS 4.0. Your simulator is most probably running iOS 4.0 while your phone - iOS 3.1.
I'm having the same problem and still looking for solution. Perhaps accessing CL methods directly will help.
try this Map.showsUserLocation=YES;