iOS application runs on iPhone but not iPad - iphone

I'm trying to run my application on both my iPhone and iPad but whilst the application runs on the iPhone, when I run it on the iPad I get the following error:
Terminating app
due to uncaught exception 'NSUnknownKeyException', reason:
'[ setValue:forUndefinedKey:]: this class
is not key value coding-compliant for the key ipad_switch_view.'
I only have the one ViewController and my iphone and ipad storyboards are the exact same. They both have a single text view and a switch which I've linked both with the same method.
Is there any reason I can't think of why this is happening? I'm still very new to iOS programming.

Check your IBOutlet in your xib or storyboard
For example . You can see in below image.
In above image lblserverDateTime is not exist in outlet .So remove
that type of IBoutlet or add into your class..

Related

App crash on iOS 5 - Could not instantiate class named NSLayoutConstraint

My app is working very fine on iPhone and Simulator with iOS 6, but when i try to run on iPhone/Simulator with iOS 5 the app crashes
The error is:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
I'm not using Autolayout on Interface Builder Document.
Could anyone help me?
Autolayout is not checked
make sure you have unselected use autolayout in interfacebuild
You've been burned. NSLayoutConstraint only exists on iOS 6. You have to check to see if it's there, and if it's not, you have to do something else.

Error After Duplicating Storyboard

Previously i had an existing iphone project.
Afterwards i want to create its iPad version so I duplicated the existing iPhone MainStoryboard to save my time, so I changed the line:
targetRuntime="iOS.CocoaTouch"
from the new storyboard (named MainStoryboard_iPad) to:
targetRuntime="iOS.CocoaTouch.iPad".
Finally I set Main Storyboard in iPad Development info to "MainStoryboard_iPad. But I don''t know why some how i got this error:
2012-10-11 13:28:07.852 CollViewSmpl[3170:c07] * Assertion failure in -[PSUICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2372/UICollectionView.m:2249
2012-10-11 13:28:07.878 CollViewSmpl[3170:c07] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier cellID - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
Anyone know what could cause this error and give me some workarounds? FYI, I use open source PSUICollectionView library inside the project in place of UICollectionView
That inconsistence error is because the storyboard source code were not being saved properly. Finally i created a new storyboard document targeted for iPad. I copied all source code of the preexisting iPhone storyboard and pasted them into the new one. I didn't forget to save the document (this is important) and gotcha, all the stuffs are now working very well.

removing a #property etc. generated by Storyboard and XCode

I'm trying to switch over to Storyboard from IB and code but got the following problem. Xcode created a #property with #synthesize and the viewDidUnLoad methods but I now don't need it and if I try to delete it, the code crashes. To make things worse, I in the meantime had connected it to a UIButton (I changed the class to allow this) by mistake. When it crashes, the code gives the message:
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[
setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key lock.'
The question is the following. Where does XCode put the code for this and what do I have to remove to get back to where I started from?
Sounds like you have a connection set up in your nib that uses that property. If you delete the property, you need to update your nib to not try and set it.

iPhone App view fails to load in iPad but loads in iPhone simulator

I am simulating an "iPhone-only" app in iPad. The binary simulates fine in the iPhone simulator, but when attempting to simulate in the iPad, the initial background image appears, but then the screen just goes black. (Xcode v4.1, SDK 4.1)
The app has only one view, which is controlled by a single custom UIViewController. (SoloViewController) The only view managed by SoloViewController is contained in a "detached" nib called "mainview.xib".
I initialize the SoloViewController in my AppDelegate like so:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
SoloViewController *vc = [[SoloViewController alloc] initWithNibName:#"mainview" bundle:[NSBundle mainBundle]];
self.soloViewController=vc;
[vc release];
[window addSubview:[soloViewController view]];
[window makeKeyAndVisible];
}
My Info.plist file has the "Main nib file base name" set to "MainWindow", which I believe is the default Xcode gives you when you first create a ViewController-based project. Anyway, I just left that as-is. However, when attempting to simulate in iPad, the log says:
Failed to load NSMainNibFile MainWindow.
iPhone simulator and hardware have no problem with this...
If I set the "Main nib file base name" key to "mainview" to use the xib file for the view, I get this error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x7a01270> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
I've double-checked the xib in IB and all of the outlets are properly defined and connected to SoloViewController.h & SoloViewController.m. What am I doing wrong here!?
Also - if I leave the NSMainNibFile blank, then the iPhone simulator just comes up with a black screen. (no errors in log)
As it turns out the project, in this case requires a MainWindow.xib file. In my case, I had inadvertently removed this file from the original project template and thought it was ok, since it simulated and ran fine in hardware. (iPhone) The MainWindow.xib file requires a File's Owner of type "UIApplication", First Responder of type "UIResponder", an App Delegate of a custom type pointing to your application delegate. (name will vary depending on what you've named your project) Lastly there is a Window of type UIWindow. All of these are default settings, with exception of the App Delegate.
Once I included a xib configured this way, the app loads as expected in both iPhone & iPad simulators. (Still not clear as to why the iPad simulator treats the absence of the MainWindow.xib file differently)
Similar behavior can happen when you reference constants in your code (or via IB code-generation) that are defined in iOS 4x or later, while the iPad runs 3.2x, and knows nothing of these key definitions.
Make sure your target has the iOS Deployment Target set to iOS 3.2 and the Base SDK to 4.1. If you changed these values, do a clean before recompiling. Unfortunately, I don't think you'll see a compiler warning in this case.
Hope that helps.

Adding UINavigationBar to a UITabBarController

Ok so I actually got to add UINavigationBar inside a UITabBarController using the following tutorial: http://twilloapp.blogspot.com/2009/03/how-to-embed-navigation-controller.html
But now the issue is that whenever I add a new button inside one of the views it just crashes.
For example:
In the first view called FirstViewController I added:
IBOutlet UIButton *test;
Than I also created:
- (IBAction) doSomething:(id)sender;
I hook up the test button with the UI in interface builder. But when I run i get:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x3b12e80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key test.'
Not sure what's going on with this.
Does anyone know of a solution?
Also, does anyone know where can I find good pre-built templates for these kinda apps so I can just start working rather than editing and setting things up.
Thanks
When you unarchive the nib file at runtime, it's going to invoke setTest:aButton on your controller, which will redirect to setValue:aButton forKey:#"test". Since it's throwing an exception that it doesn't know what the key #"test" means, chances are you forgot to put the #synthesize test; in your FirstViewController.m file.