iOS7 UIToolbar crash - ipad

I have an iPad app that has been running fine until iOS7. This issue seems to be only on ipad 2nd gen models and earlier when iOS7 is installed. Anyway, I've been tearing my hair out trying to figure out where this error is coming from, but have had no luck. The console in xcode (5) reports the following error after I perform a logged in segue:
2013-11-18 11:17:31.768 MyApp[400:60b] *** -[UIToolbar backdropView:willChangeToGraphicsQuality:]: message sent to deallocated instance 0x18ec23e0
I can't lookup the address for more info (image lookup -a 0x18ec23e0) it just returns nothing.
In instruments running zombies, it reports that a message was sent to a UIToolbar like so:
When I inspect the instance, I get the following:
How do I debug this? I have no idea where this call is being made and it seems dependent upon a physical deivce (doesn't happen on the iPad mini or ipad 3/4)

I was struggling with a very similar error, also with a UIToolbar, that I couldn’t figure out until a couple hours ago. I also had to use and try to understand the zombies’ instrument but without any luck.
What I did was to pay a close attention to the call stack that was presented when the Exception Breakpoint was activated as described in the following tutorial:
http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1
Even though the call stack didn’t point me to the exact code line, I noticed that the app was trying to add a UIToolbar to a ViewController. Turns out that what I was doing was creating a local UIToolbar inside of a method and adding it to the presented UIView. After have modified this behavior, I stopped having the annoying sudden crash. It was difficult for me to find the issue because looking at the code of the ViewController that caused the crash, there was no code that created or used a UIToolbar; however this VC included a custom view that did exactly that, as I explained before.
Have said all of this I recommend you to closely inspect the VC that generates the crash. If you need to create a UIToolbar programmatically I recommend you to declare it as a strong property to maintain the memory reference as long as needed.
I hope this helps you.

I struggled with this for a while today. I had two storyboards, one for login/signup (set as the main storyboard for the project) and another with the rest of the application. The app delegate would detect if a user was logged in and instantiate the root view controller of the other storyboard. The root view controller of the login storyboard is a navigation controller and after after some investigation with instruments I realized there was a UIToolbar being instantiated from the nib. Opening up the storyboard file revealed an off-screen UIToolbar object in the root view controller. I deleted it and I'm not crashing any more.
I should also mention this crash was only occurring when I was using MKMapView.

Related

Getting random crashes while pushing to another view controller

I am getting random crashes while pushing to another view controller.

It was too difficult to find out such a crash, we spent the almost 2-3 days to solve this issue. seems like the crash was due to the one extra view outlet got connected to the main view in the storyboard. Which created the nil reference for some objects of the view controller and applications crashes.
But something surprising to us that how Xcode allowing me to connect the two outlets to the main view. I have again tried connecting the same but this time it is not allowing me to connect.  Attaching the screenshot for the same.

Any kind of help/explanation is appreciated.
Please add crash logs. We should check them. Theres any data moving between two ViewControllers
It is problem with Xcode sometimes while editing the outlets.Find the controller on which app crashes and reconnect the outlets and run again.I don't know the exact reason but that solve my problem.

iOS 9 Segue Causes App To Freeze (no crash or error thrown)

I have been working on this app for months now and from as far back as I can remember I have never had an issue with segues. The code is unchanged in terms of calling performSegueWithIdentifier but since my recent update to Xcode 7 and iOS 9 I have not been able to tack this issue.
I have tried:
Deleting button and creating new button w/ segue link
Using a direct segue from button to view, without the use of performSegueWithIdentifier
Connecting button to new blank viewController
When I press the button, no initial load functions are called on the destination VC (Ex: ViewDidLoad, ViewWillAppear, etc). When I connect it to a blank view, the segue works fine with the same code in place.
Since the code never stops, or breaks, and just seems to "freeze" in place while still running on Xcode I can't seem to even narrow this down to whats causing the issue. I have a similar segue that is also called from another button on the same ViewController that has no issues whatsoever.
Any thoughts on the matter are greatly appreciated!
EDIT: I have narrowed the issue down to the UITextView's causing the problem. Once the Text Views were removed the page loads fine via segue. I wonder what changed between iOS 8 and iOS 9 in terms of UITextView as I will have to remove the text views and completely re add new text views.
So basically the segue was freezing because of the UITextView's I was using in the destinationViewController. The following fixed the issue:
Delete all UITextView's
Add new UITextView's
you must leave the default lorem imposed text and change this programmatically in the viewDidLoad()
This was the fix for me, and from the research I have done on the issue it seems this is a bug in iOS 9 and Xcode 7.
Cheers!
NOTE: Removing the text in the UITextView (or making it longer then ~12 characters) is sufficient to work around it, no need to delete and recreate them. This is fixed in Xcode 7.1.1 and later.
I ran into the same issue and the fixes in this post (Xcode 7 crash: [NSLocalizableString length] 30000) solved the issue for me.
The first is to enable a localisation other than the base for the storyboard (see https://stackoverflow.com/a/32688815/3718974)
The second is to turn off the base localisation (see https://stackoverflow.com/a/32719247/3718974)
I think I have the same problem: I have a UITabelView with cells created from a nib file, when a user tap a cell this method is called:
and when I have the following method prepareForSegue:: the application crashes:
if I delete the line 129 Everything is ok , the method prepareForSegue:: open the right view and the label contactName is shown with its default text.
If I modify the method as follows prepareForSegue:: get exactly what you expect, without having any type of error:
let me know if you also get the same result
Any one who is facing this issue, i solved it by turning off the "Optimize rendering for windows scale" option in Debug of simulator window. I already had tried all of the above answers but could not solve the issue.
In the method in the first viewController where you activate the segue, do you have beginIgnoringInteractionEvents anywhere? If so the screen you segue to will be frozen and will ignore interaction events like you describe. If this is the case you can fix this by adding an endIgnoringInteractionEvents method before your segue method:
UIApplication.sharedApplication().endIgnoringInteractionEvents()
self.performSegueWithIdentifier("editItemToMyGearSegue", sender: self)
I realize this is an old topic, but appears to be still relevant. I was facing the same problem in Xcode 9, iOS11. My UITextViews are embedded inside UITableViewCells. Same symptoms as described here. The tricks with default text and placeholders did nothing for me, but I solved it by turning off the scrolling indicators for the text view in the xib. They were on by default, I guess, though unused.
Edit: this is probably an important detail... the views that were hanging all had an image NSTextAttachment in the attributed string of the text view. I think the image was wider than the available table cell content. With scrolling turned off, they appear to downscale.

_hideForKeyboardAppearance error when clicking on UITextView

I have a UITextView, and whenever I click on it, the app crashes with the following error:
-[__NSSetM _hideForKeyboardAppearance]: unrecognized selector sent to instance 0x7fb8aa76cd60
If I run the app multiple times, it always crashes at the same place, but the intercepting object that is throwing the "unrecoginzed selector" can be different. Sometimes it is UIImage instead of NSSetM, sometimes, it is a UIConstraint, etc.
Even if I don't assign the UITextView to a specific outlet in my class, or have it assigned to a delegate, I get the same behavior. This happens on both simulator and hardware.
Any ideas what is going on?
p.s. this is iOS 8. Crash happens on both iPhone and iPad.
Edit: Note that this happens even though the UITextView calls no code. I removed any outlet connections in the storyboard, and even made it so my class doesn't implement UITextViewDelegate. Still crashes. That is why I am so puzzled and wondered if anyone has ever encountered something like this. One thing to note is that the view controller having this issue is buried several screens deep within a UISplitViewController. Not sure if someone UI elements buried deep in the nav stack are somehow intercepting the keyboard call?

Weird crash while navigating back

My app crashes randomly when navigating back in a NavigationController. Here is what I know:
It happens randomly (sometimes, I can come back once or twice and if I reload the viewController and press "back" again it will crash)
It happens even with an empty ViewController (I tried to comment out all my code in ViewController.h and .m and to remove all the outlets links)
Nothing shows up in the debug console, only a EXEC_BAD_ACCESS is shown in main.m
I spent the afternoon on this and tried everything.
I don't include code right now because I have no idea where to look. As I said, it even happens with an empty ViewController.
Any thoughts or similar experience ?
EDIT:
Yes I tried to add an exception breakpoint
I even tried to find some observer issues with Spark debugger.
EDIT 2:
Actually, the ViewControllers were not that empty. The import on an UIView category was the problem. Check my answer below.
It's difficult to say exactly what could be causing it without more information, but in my experience the most common reason for an EXC_BAD_ACCESS is when someone tries to call a selector on a deallocated instance. This issue can be a lot easier to debug if you enable zombie objects.
Edit Scheme -> Diagnostics -> Enable Zombie Objects
Now instead of getting a bad access exception you should get a more helpful "message sent to deallocated instance" error (assuming that's actually the problem), along with what method was being called on which class of object.
The problem was that some of my views were importing a custom UIView category that included a dealloc method. I deleted the dealloc method from the category and everything is fine now.

Runtime error: Unrecognized selector sent to instance

I'm new to using a mac and iOS development. Today I followed this tutorial on to a how to bind data to a table view by making use of Prototype cells and the Story Board. I've got up to the part of the tutorial where I should be able to run the app so the bound data shows up in the UITableView like this:
My app compiles fine, but as soon as it starts running it hits a runtime error:
[ViewController viewControllers]: unrecognized selector sent to instance
I have tried going through the tutorial several times now. I've followed the tutorial exactly as it says and have even created 3 different projects from scratch to make sure that nothing is going wrong. Can anybody help me fix the error? I've spent hours trying to work out what's going wrong, and I don't want to give up now as iOS development seems so exciting compared to other platforms!
Unrecognized selector means that there is an undefined method being called.
One thing to do is to see if there are any compiler warnings. Does it give you any? Have a look, it may give you a clue what is undefined.
The tutorial refers to ViewController class. It looks like that this class is used briefly at the start of the tutorial but then it is replaced with another class. You may remove this class later on altogether. Check if you wire tab bar controller properly. have you set it to be "an entry point"?
Check the storyboard. Where does an incoming arrow point to? Compare two images below. First has the entry arrow pointing to ViewController (my guess), second - the arrow point to Tab Bar Controller
.
At some point (without the code is hard to tell where) you are getting a reference to a ViewController, treating it as a UITabBarViewController.
viewControllers is a method of UITabBarViewController but you are invoking it on a ViewController.
You probably have something like
UITabBarViewController *tabBarVC = (UITabBarViewController *)[something aMethod];
tabBarVC.viewControllers...
So it compiles fine, but it rightfully crashes at runtime.

Resources