I am setting the userTrackingMode of an MKMapView instance in my UIViewController's viewLoaded method. The first time the view loads I set it to MKUserTrackingModeFollowWithHeading successfully. However every subsequent time the view loads, though I again set its value to MKUserTrackingModeFollowWithHeading, this is almost immediately overritten by MKUserTrackingModeNone. I have subclassed MKMapView and overridden setUserTrackingMode, inserting a breakpoint so I can see where it is being called from. The same thing happens in both simulator and on device:
On simulator I get the following from the stack when the value is set to MKUserTrackingModeNone:
On my device (iPhone 4s) I get the following:
There is very little else going on in my application and certainly nothing that is directly triggering the property to be set. What is CLSqliteDatabaseManager? Google returns not a single result. On the device how on earth can MKMapRectContainsRect be involved? I'm using iOS 5.0.
It seems too late to answer. But it may still be helpful for whoever is looking for an answer.
I had exactly same problem. Suddenly I figure out why. Please load your iOS build-in Maps app and click the small arrow button at bottom-left corner to start tracking your location. As soon as you drag the map. The tracking is stopped. Same reason, if you move the map in your code, the MKMapView property userTrackingMode will be reset to MKUserTrackingModeNone automatically.
In my case, I called setCenterCoordinate after set userTrackingMode to MKUserTrackingModeFollow in - (void)viewWillAppear:(BOOL)animated. It worked fine after moving around the code mapView.userTrackingMode = MKUserTrackingModeFollow; to the end.
Related
I have a UIView in which I display a movie if a particular chapter demands it. This view is resized via constraints in Main.storyboard to adapt to iPhone. All works fine on iPad. It also works fine on iPhone unless the app is asked to reload when a movie containing chapter was last active meaning that a movie will be first-up on loading. In this scenario, the movie is loaded into the iPad dimensions instead of the smaller iPhone specs.
It appears that the constraints on the movie's view are not engaged in a timely manner. The issue centers on a query of the the view's bounds. If I insert a delay before using the bounds the issue goes away. In fact, a delay of 0.0 seconds does the job!
Using a kludge that relies on a delay seems pretty funky to me. I can also move the call that uses the bounds to viewDidLoad to resolve the issue but then I see some underlying “garbage” when reloading the app, the launch image seemingly not in effect. Any suggestions?
It sounds like you're using bounds before your views have been lain out. Without actually seeing your code, I would suggest executing your described code inside of viewDidLayoutSubViews().
I came across the scenario where in if after moving the map immediately if I tap on back icon while the map has not fully loaded
The application crashes.
What I can understand is Since the loading is still in progress and I tap back the the application releases the controller but the google map loads asynchronously in NSRUNloop (not sure). So that might be the problem not sure though.
So does anybody know what can be the issue and is there any way to solve this issue?
Please comment if more description required.
It sounds like that when you close the view, the object that is the delegate for the completed map load has been deallocated, causing the crash with a bad access.
A good way to get to the bottom of these types of crashes is to use Instruments (part of the Xcode suite to tools) and go zombie hunting.
For anyone who is still searching for the answer
What exactly happening was that map view events were getting fired even if the controller was released causing a crash in the app.
So the solution is Before setting the value of objMKMapView to nil you need to set value of objMKMapView.delegate to nil.
I have an app where I have 5 sets of animations that I'm storing in an array. The animations get picked to play randomly after a button touch. This is all working perfectly, however I noticed a bug when I quit the app and reopen immediately, I'll see my main view, then it'll jump to my second view that has the animation in it. (This shouldn't happen since you have to tap the main view in order for it to modally swap in the second view. If I interact with it everything works for a few seconds, then it closes with no crash log.
I finally realized that some of the objects must not be getting released fast enough, since if I close the app and wait three seconds, then reopen, everything executes fine.
I didn't want to put down code to show as this is more of a brainstorming question. I'd love any insight that could point me the right way. I changed a lot of my code to get rid of convenience methods and have all my variables defined and then released in my dealloc.
Is there a way to truly tell the app to kill everything on quit? It's not set to run in the background so this is a bit odd. Thanks for your help I'm still new to this and learning!
Alright, after working on this all weekend and doing more research comparing a barebones version of my app to my prerelease version, I traced memory leaks to the Flurry Analytics api that I am using. Apparently I was suffering from the same issue as the post here: App hangs on restart with latest Flurry SDK and ios4 . I resolved this by setting these optional methods to false, since they take extra time to send data after the app terminates, and depending on the connection it takes a few seconds.
FlurryAnalytics.h
/*
optional session settings that can be changed after start session
*/
+ (void)setSessionReportsOnCloseEnabled:(BOOL)sendSessionReportsOnClose; // default is YES
+ (void)setSessionReportsOnPauseEnabled:(BOOL)setSessionReportsOnPauseEnabled; // default is YES
Hope this helps anyone else who experienced something similar to me!
All apps can enter the background by default. Normally they do not do anything there, but they stay there in a frozen state and when you open them again, your program does not restart, it just picks up where it left off.
Anything that's set as an animation delegate might not get released, since it's retained for that purpose until the animation completes.
You can add an applicationDidEnterBackground: method to your app delegate to get informed when your app is going into the background, but exactly what you need to do depends on the design of your app. You can also add applicationWillEnterForeground: to do anything you need to do differently when restarting, as opposed to newly starting.
You might be able to force your animations to complete by starting a new animation with duration 0.0 (or very short if for some reason you can't do that).
If this happens only if your app goes to bkgnd and comes back AND you don't mind if the app restarts everytime it comes back then just put UIApplicationExitsOnSuspend in your app's plist. In all my cases where these and other bad things happen with apps going to and returning from bkgnd this helped.
While you might still see the app on the buttom when double tapping it is really stopped and will restart. Apps that show on the buttom do not always have to run or be stored in the bkgnd I learned.
ps. don't forget to set the value of UIApplicationExitsOnSuspend to YES
In my app I have a rare bug that stops showing the userlocation. If I tone the app down and just have the map, and set everything up in the viewDidLoad, and at the end do the typical:
myMapView.showsUserLocation = YES;
everything works great 99% of the time. It always works when the App is starting from scratch, but like 1 time out of 100, when resuming from the background, the userlocation doesn't show. And even if I make a button to turn showsUserLocation back on, it still won't show (and upon doing NSLog's the property shows that it is set to YES in the MKMapView). If I kill the program, and start it again, it works fine again.
Everything is being done in the main thread as well.
Anyone encounter anything like this?
you can refer this image for fetch location in backgroud Mode
I'm playing around with the TV-out Adapter for the iphone. My goal is to have an external window display on my tv in order to play movies from my iphone.
the big problem I've got now, is that if the phones orientation changes (physically) the window that shows on the tv turns as well. which is of course unwanted behaviour..
So far i return NO from shouldAutoRotateToInterfaceOrientation. But it still turns and turns.
I'm very grateful for any help on that topic
cheers
sam..
Ah well the solution was rather simple.
I had to assign a RootViewController to the Window that I'm using. Said Rootviewcontroller then needs to implement a shouldAutoRotateToInterfaceOrientation Method (that of course returns NO).