how to remove image stuck in my nib after all references removed - objective-c

My iPad app will periodically crash with a memory warning, and it shows "Could not load the "myimage.png" image referenced from a nib in bundle..."
I have removed this from my .h and the nib and it, obviously is not in my bundle. I cannot get rid of this reference. I have checked everything there is no pointer to it in my nib or in my code, how can I view my nib such that I can get rid of this bad reference??
Anyone else experience this?

Never seen that happen but you could just open the .xib file in a text/xml editor and do a search for myimage.png. CHeck that out and infer the problem from what you find :) Post what you find if you cannot get a solution from that.

Related

subclass of UIViewController is unable to call loadView method

i have a subclass of UIViewController, and when it is called from another class the app just freezes - i used the Xcode debugger and figured that when I'm trying to access the class's view property the app freeze. another weird thing is that when i type in the debugger control panel: "po objectOfTheProblematicClass.view" the debugger stops responding.
the code I used was similar to this:
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"Main" bundle:[NSBundle mainBundle]];
WTStickyViewController *stickyVC = [sb instantiateViewControllerWithIdentifier:#"WTStickyViewController"];
stickyVC.sticky = sticky;
// Setup view controller containment:
[self.parentViewController addChildViewController:stickyVC];
self.containerView = self.parentViewController.view;
[self.containerView addSubview:stickyVC.view];
WTStickyViewController is the subclass of UIViewController. the app freezes when it reaches
[self.containerView addSubview:stickyVC.view];
but it's because this is the first time that stickyVC.view is called.
if for example i would put somewhere in the code
UIView *viewForExample = stickyVC.view;
the app would freeze there.
the exact same app works fine when compiled on a device with iOS 8 but has this problem with iOS 9.
if anyone knows why is this happening and if there is a solution it will be great. thank you.
I was having a similar issue and it was absolutely maddening. The CPU went to around 100% in the resource monitor during debug as the app deadlocked. Printing to console or just generally accessing the view controller's view property caused this behavior. Ultimately, what 'fixed' it for me was removing it from the base localization file. I know that doesn't make sense, but I'll elaborate as best as I can.
I'm maintaining a legacy universal app that has 2 'main' storyboards called Main_iPhone and Main_iPad, which as you can probably guess are the loaded dynamically based on what device you're launching on. I noticed that only the iPhone nib view was deadlocking as described, and iPad was loading fine. The only thing I could tell as that the iPhone storyboard had localization enabled while the iPad storyboard had not. So here's the steps I took loosely to remove it from base localization (you may want to do this in a separate branch/sandbox to make sure this works before deleting project references):
Right click the problematic view and/or storyboard in question, show in finder. For me it was inside the Base.lproj folder as expected.
[Re]move the file to a different directory so Xcode can not find the link the project (file goes red in file browser). Press delete to remove the file from the project file's reference from the project itself.
Add the file back at the new location in your repository/project structure so Xcode picks it up as a new file. Ensure all of your references to the file are updated to the new location.
Verify your storyboard/xib file is not localized anymore, clean project, re-run and see if the issue is still there (see image).
You can also just update the file location using the update location button in the file properties view on the right side (see other image).
Don't know if this will fix it, but I thought I'd share what helped me in the chance that it helps others as well.
A bug report was sent to apple and hopefully it will be fixed soon - the problem is indeed with Xcode 7.
If you are encountering a similar problem, it can be solved by doing one of the following:
1) Use Xcode 6.4, at least until apple fixes this bug.
2) Rebuild the problematic view in the storyboard.
I will post the radar link once I got a chance to speak with my manager about it...

Error loading .xib - application crash

I am banging my head against a brick wall. I am trying to push a view onto a UINavigationController in the usual manner:
[[self navigationController]pushViewController:vc animated:YES];
When I do this the app crashes with the following error:
__CFStringEncodeByteStream + 17
Thread 1: EXC_BAD_ACCESS (code=2,address=xxxxx)
Now, I have replaced the ViewController in question with a template provided by XCode and I do not get the error so the issue must be with my UIViewController class. Furthermore, if I replace the nib name with that of the template UIViewController class it works .i.e.
MyViewController *myVc = [[MyViewController alloc]initWithNibName:#"XCodeViewController" bundle:nil];
This leads me to think that the issue is actually with the nib and not the class itself. I have checked through all the connections and there are no errors or warnings.
Hopefully somebody can help.
Thanks
I was dealing with a very frustrating bug similar to yours, and everything was in place.
The newly created xib was added to the Bundle resources, no nil pointers or released pointer, NSZombieEnabled was set. The File's Owner was set to the correct ViewController as well
After sitting down with my senior for 30 minutes, we finally realized what was wrong -
In the newly created Xib, even after you assign the File's Owner to the ViewController there is an additional step which you need to take.
You need to have the main View's referencing Outlet set to the File's owner as well. The easiest way to do this is to Drag the "+" sign on the referencing outlet(From the Connections inspector) to the "File's Owner" in the Document Outline. After this you just need to click on "view" which pops up and you should be good.
Hope that helps you or anyone else facing the same problem
Need more info to answer, I can give few possibilities.
Check if the class name is mapped properly in your identity inspector.
And check your connections too. If your view is mapped in xib., etc.
If your running the app in OS below 6.0 & built with features such as Auto layout, it leads to crash.
There are multiple possibilities.
Hope this gives an insight.
Check if your nib is added to the application bundle. You can do that by selection you project file->Build Phases->Copy Bundle Resources.
If it is not there, add it.
I had the same issue yesterday and this was the problem.
I hope it helps.

iOS6: UIViewController was unable to load nib named

When testing in the iOS6 simulator, I am getting the following error when clicking a disclosure indicator:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] was unable to load a nib named "LocationDetail"'
It runs perfectly fine in iOS5.
I do NOT have the LocationDetail nib anymore, nor need to use it. I have looked in my entire project for references to it, as well as in my MainWindow nib and all connections looking to see where it could be used, but I find none.
How would XCode still be wanting to load this, and why only the errors in iOS6?
The problem is not in Xcode, but in the iOS Simulator. If you've removed all references to the .xib in your project, and cleaned everything as you described, the problem is that the .xib file still exists in the app bundle in the Simulator. You should try deleting the app from the Simulator (or better yet, Reset All Content & Settings on the Simulator). This will fix it.
what i know is that initWithStyle:UITableViewStyleGrouped will call the initWithNibName:Bundle: method...
your class had the same name as your nib file, so when you called the initWithStyle:UITableViewStyleGrouped it tried to load that nib file.
when you renamed your class, it didn't find an nib with the same class name so no errors showed up as before.
I decided to just rename my class and .h and .m files and that fixed the issue.
Who knows why.

presentModalViewControllerAnimated: gives white screen

Hey all. Something which has been bugging me quite a bit recently is this custom movie player I've put together. It's largely based on a working one, NGMoviePlayer.
The issue is this: I have the .xib in a UIKit-friendly resource bundle. When I call:
[MyMoviePlayerViewController initWithNibName:#"MyMoviePlayerViewController"
bundle:[NSBundle bundleWithPath:
[[NSBundle mainBundle] bundlePath]
stringByAppendingPathComponent:#"MyMoviePlayerViewController.bundle"]];
..on my custom class, and then access the view (thus calling loadView) it doesn't throw any errors, but nor does it actually load the outlets properly. I am presented with a white screen, and debugging shows that all visual elements are 0x0, but there was no error as would be expected.
EDIT: I've also now tried just loading the .xib outside of a resource bundle in my target app, and the same thing happens (white screen).
The particular ones I was looking for was either:
Could not load NIB <nibname>... if it wasn't found at all, or
...loaded the <nibname> NIB but the view outlet was not set if it was found but not connected properly
The xib is in the local app (I understand that static libs can't contain xibs). I've tried using this same resource bundle with the NGMoviePlayerDemo project provided by the author of NGMoviePlayer, and it does throw an error:
Could not load NIB in bundle:
'/Users/.../MyMoviePlayerViewController.bundle (not yet loaded)'
with name 'MyMoviePlayerViewController'
I have navigated to the path it displays for the bundle and there exists a MyMoviePlayerViewController.xib file at that location.
I've also tried using bundle:nil in case Xcode combined the resources of bundle directories with the main one for some reason. Both cases throw no error and display a white screen in my actual project. Both cases throw a Could not load NIB error in the NGMoviePlayerDemo project.
EDIT: I have tried the same .xib separate from a resource bundle in the NGMoviePlayerDemo app and it works fine.
All input is greatly appreciated.
Solution: Pay attention to Unknown class <classname> in Interface Builder file. messages.
I had the code for the movie player in a static lib, and the parent view controller for the movie player was being included in the project as an external header, but the subviews weren't included as headers, so they weren't being located properly. Because the only place they were being referenced in my target app was within the .xib file, there were no compile errors to do with those subclasses, but when it came time to load the .xib those classes could not be found, so none of their properties were set. And that just so happened to include all of the controls for the player, which probably then made the initialisation code silently fall over.
I merged all of the code and ivars from the subclasses into the parent movie player class, and it's working fine now :)

Cocoa - Loaded nib file disappears when focus is lost

I have a nib file I've loaded like so [NSBundle loadNibNamed: #"myNibFile" owner: self ] and it pops up fine, but when it loses focus, it simply disappears. I've checked to see if it's vanishing behind my main window but it's not. My app is pretty big so I'm not sure what could be causing it. I have garbage collection enabled if that makes any difference. Does anyone know of any problems with loaded nib files and losing focus that I should look into? If necessary I can start posting some samples from my code.
Hmmm... I just deleted the nib I was loading and recreated it and it started working. Strange... Seems fixed now though.