MKMapView overlays get reset on appDidBecomeActive - iphone

I have this map view with a bunch of overlays. When I hit the home button and re-open it, all the overlays disappear for a second and immediately re-appear. At first I thought it was my code that was doing it but I put breakpoints pretty much everywhere and none of my code seems to be triggering the "reset". Even mapView:viewForOverlay: doesn't get called before the overlays reappear.
I thought maybe this is an inevitable behavior of MKMapView, but it seems like Maps.app doesn't do it either — if you calculate a route and quit/re-open the app, the overlays stay there the whole time.
I'm thinking maybe MKMapView clears all of its annotations/overlays by default on quit so it takes less memory while staying backgrounded. Is there any way to avoid this? Kinda like Maps.app does?
EDIT: here's a small project I put together to demonstrate the problem. Just launch it in Simulator, click the home button, and re-open it. You'll see the map path overlay disappear for a moment.

This is more of a follow-up than an actual answer, but basically this issue has been flagged as a bug by Apple. I submitted this as a TSI to Apple a while ago and received the following answer:
Thanks for providing a sample project. I don't see any issues in your
code. At this point I recommend escalating the issue to engineering by
filing a bug about the "flicker" from the MKPolylineView being redrawn
at https://developer.apple.com/bugreporter/ and sending me the bug
number so I can use it to follow up.
I then submitted radar #11041378
Thanks again for your bug report. As it happens, I don't have a
workaround for you at this time. Engineering is still working on the
issue, but I don't have a timeline for a fix.
I'll go ahead and leave this incident open for you as long as bug
11041378 is open. If you have any questions about it's status in the future, or the status of a workaround, feel free to reply back and I
will check it for you.
If you have any comments for engineering, or want to tell the story of
why it's important to your situation, I'd actually encourage you to
put that directly in the bug. Since it's been assigned to engineering,
any comments will go directly to them.
I appended the following comment that describes why the issue is important to me:
This bug feels rather important to me as the user expects to find the
app in the exact state he left it when he quit the app. The flickering
overlays (sometimes disappearing for less than second, other times for
2-3s) may get the user confused about what is going on, when all he
really wants is to interact with the map/overlays right away.
Haven't heard back from Apple since. Hopefully this will get fixed in iOS 6?

Related

Unity Interface select on Click in Scene View

Unity won't let me select objects on my scene without first selecting the object in the Hierarchy. This was all I could find on the issue.
However, it seems that they decided that closing and opening the scene window fixed the bug, but not so with me. Also note that I am on a blank project. Its been really difficult to work around this bug.
Edit:
I have even uninstalled Unity and reinstalled with the hopes that this would solve the problem, but unfortunately it did not. Thanks for any help ahead of time.
Honestly this is such an odd problem that I'm having difficulty knowing how to try and fix the problem. I also reported the bug as recommended below by NoëlWidmer, but even the staff who was very kind had no idea how to deal with the problem, and the advice he gave also didn't change a thing. Truly, I don't even know what more information I can give you guys because as I said I literally opened a new Unity project for the first time after reinstalling and was unable to select without first clicking on the hierarchy. Is this just a special freak case that landed with me or has this happened to anyone else?? Also I'm using a two year old Windows 8 Laptop with literally nothing installed on it but the Adobe suite and a few other game developer necessities, so my computer most likely is not the source of the problem.
Edit: a Clue??
Well I was messing around with the scene and hierarchy view in full screen, and I noticed something interesting after clicking on the object in the hierarchy and moving the object in the scene view:
Unfortunately my PrintScreen doesnt show the actual mouse, but as you can see the scene view acts as though I'm clicking on the object, but here at the same time I saw my real mouse off down to the right! Also while I've selected an object on the scene editor and I move my mouse off the scene window things get a bit off and the mouse will pop up on other sides of the window and so on. I don't know if that's normal and its that way for everyone or if it's just me and it might help figure out what's going on.
Man I've really been liking Unity but if this keeps up I think I'll have to drop it and find another software, because I certainly will never be able to design anything worth while if I have to select the object on the hierarchy every time for every single object.
Some bug for me on Mac platform. I resolve just entering and exit from fullscreen mode.
Probably may also work change layout with top-right combo.
I had similar issue while using older versions of unity (in addition inspector window lost the focus repeatedly). In my case rearraging editor windows and saving custom window layout solved it. As far as I remember, I just moved scene view outside Unity window (on the second screen) as well as hierarchy view, and saved resulting position as a new window layout.
Not sure if there is anything else I can tell about it, it's pretty mysterious problem.
I'm overwhelmed with joy right now!! The problem was indeed a bug. I was working on a project and moving objects around (still using the hierarchy to select objects) and then a split second later for absolutely no reason Unity decided to start working the way it should've!!! I guess its just one of those issues where you just have to cross your fingers and hope it'll resolve itself. I'm so glad this dumb issue resolved itself because I was about to tear my hair out and succumb to using another computer for my unity design, or even worse another software. Thank you to everyone who helped!

iOS: Crash when keyboard is used...?

Pretty simple bug:
Pressing any key on my Mac's keyboard causes an "EXC_BAD_ACCESS" error to occur when running an app on the simulator. Unless I'm entering data into a text field that is, where it works fine.
-
Not sure if this is a bug in my app, or somewhere else. If by some chance, someone was using a bluetooth keyboard with my app, then I don't exactly want it crashing willy nilly... small chance I know, but I'd still rather fix it if it's a bug. I've enabled zombies - doesn't tell me anything about where the crash is occurring, and the app still crashes.
Any thoughts or answers are much appreciated, thanks :)
Turning off "Auto-Correction" in the simulator keyboard settings fixed this issue for me.
Screenshot of Keyboard Settings in Simulator:
Seems there are still bugs with the simulator.
This bug is usually attributed to trying to access an instance that has already been released. Check your instances, anything that you allocated, released, and then you are trying to access. It may not even be connected to the keyboard, but maybe a delegate method. Post some code so we can have a better idea of it. For example, the code for the view controller that is running at the time of the crash.
Try to run your app with "Guard Malloc" on. You find this setting when you go to
Manage Scheme -> Run app (on the left side) -> diagnostic (on the top
lashes) -> under Memeory management.
This will show you the crash point where it happens and you should be able to find the reason much more easily

Intermittent failure of keyboard notofications

I have a view (a couple of them actually) with a standard search bar at the bottom. When the user touches the search bar, I need to move the search bar up so it's not hidden by the keyboard, then down again when the keyboard is dismissed.
I do this the same way as everybody else, by observing UIKeyboardWillShowNotification and UIKeyboardWillHideNotification. From these notifications, I get the height of the keyboard, and that tells me where to put the bottom edge of the search bar. It works perfectly, except for rare cases when the search bar doesn't animate, or doesn't animate far enough, and vanishes behind the keyboard. I have seen this a handful of times out of hundreds of tries with myself and my QA people testing on iPhones and iPods. Just once, I saw the search bar fly off the top of the screen as the keyboard came up. We've never seen any of this on the simulator, and we see it more often on the iPod than the iPhone. We are running iOS 4.x, mostly 4.3.3.
So I can think of two possibilities. One is that very occasionally UIKeyboardWillShowNotification is not sent and the other is that the data in the notification is wrong. The second one would explain the one case where the search bar flew off the top of the screen.
And then of course it is possible that my code is wrong in some very devious way; but the scenario is so simple -- enter the view and tap the search bar -- that I can't see how a bug in my code could cause these rare and intermittent failures.
If anyone can offer insight, I would be very grateful.
I finally discovered the answer to my question, and it's interesting. To cut to the chase, my search bar is animating into the wrong position; in some cases it's still behind the keyboard, and in others it's off the top of the screen. This is not caused by wrong data in the notification, but by a bug in accessing the height member of a CGSize or the y member of a CGPoint.
Specifically: in certain scenarios, when you write mySize.height, the generated code accesses mySize.width. If you are reading, you get the value of mySize.width; if you are writing, you clobber mySize.width. Similarly, myPoint.y actually accesses myPoint.x.
You may never see this problem. I only saw it on older iPod touch devices running iOS 4.2.1, and only in Release builds, and only when compiling with Apple LLVM Compiler 3.0, and then maybe only sometimes. But I reported it to Apple and they say it's a duplicate of a known bug (#10043857) that they are addressing. Connecting a few dots, I am guessing that it's somewhere in the compiler chain in Xcode 4.2.
The workaround is to take the address of the CGSize or CGPoint struct, then use pointer arithmetic to access the desired member. I wrote a set of little helper functions to do this, and I call them all over my app's code.

Replace UINavigation with UIToolbar?

I've built a Navigation-based app, but now that I'm knee-deep in the code, I've decided it would actually be best to have just a UIToolbar instead (only need modal views, not drill-downs). But extricating the Navigation stuff and replacing it with a Toolbar is causing me all sorts of grief...
Has anyone ever done this, and maybe has a pointer or two? Or even know of a walkthrough linked somewhere?
Thanks!
Bite the bullet and rewrite. Any guides out there will not be specific enough to your situation.
99 times out of a hundred if I realise I've made a massive design mistake and don't change it, I end up regretting it more than if I do. And since you'll take a copy/start from scratch again, you can always revert if you need to give up half way through!
Seriously, because this is a current app that is still (relatively) early in its development life and is all fresh in your mind it will very likely be quick to re-do. Also, sounds like this might be one of your first iPhone apps so you're likely learning new stuff every day - now you get to put all the new stuff in this app too. And finally, just imagine the work involved if you put another 200 hours into this as it is and then decided you had to rewrite!!
Hope that helps, and I bet you get it rewritten in less than a day!

iPhone Bug App bug Question and challenge

Ok so I've got a really annoying bug in my app. It's driving me crazy and I'm sure it's beyond my skill level as I am learning as I go.
Here is the initial rundown of the bug: A shot in the dark - Application bug
However I have found a way to consistently reproduce the bug (only on the device not in the simulator)
First you create a new Pool and save it. Then add 20 blank time entires into one day. Save it and this is where the problems begin. (when you go back to the main detail view the tableview has put itself out of editing mode with being told to do so). Now if you go back to the day to see the time entries you just added they are still there.
If you go back to the main overall tableview listing all pools and now go back to the day you added the times they have dissapeared.
Add one time and it all saves fine. Add twenty and it doesn't save. WTF!!
Main Menu listing Pools:
Detail view:
Edit View:
Time Edit View:
Add a time:
I'd appreciate any more guesses. But as well as this question I'm offering a bounty of £25 (Sorry I'm a poor student) to whoever is good enough to fix this bug first!
if your interested my email is danmorgz[at]gmail.com
Thanks,
Dan
If you haven't already done so, I'd recommend turning on NSZombie support and seeing if you're using any of your objects after they've been freed. As far as I know this can be turned on in the simulator and on the device.
Most likely, you're failing to retain some object somewhere along the way. When an object gets released and then the memory is re-used for something else, you'll get all sorts of bad behavior, including crashes, or mysterious "disappearance" of other objects.
One thing you can try is putting breakpoints into the -dealloc method of your custom classes. Then you can see where they're getting deallocated from. Most likely though, this will end up being when the AutoreleasePool gets drained, which won't tell you much.
Alternatively, look into using some of the memory debugging tools built into Cocoa.
That document is for Mac OS X, but I think most all of this will work in the iPhone simulator, at least. I know that your bug "doesn't happen" in the simulator, but that really only means that the symptoms are different, and you're not noticing them.
Thanks for all your answers. It's now fixed.
For those interested I'd forgotten to add a cellidentifer in the XIB of my cell subclass.
cellForRow: method was therefore creating a new cell every time. The memory got filled up very quick. It then seemed as though my app was automatically trying to cut the fat by forcing another tableView out of editing mode and not managing my instances properly.
Again it's a memory problem. Isn't this always the case!?!
The clue was a one off 101 error in the console indicating my app was using too much memory. Oh and a slow scrolling tableView.