Is there any way to specify nib name such that application automatically pickups corresponding nib for landscape or portrait when there is change in orientation.Like for iphone 4 and iphone 5 there is Default@2x.png and Default-568h@2x.png something like that.If not?,I am trying in app delegate method to addObserver for orientation change and it is working fine but while changing nib in orientationChanged method cause app to crash and produce error as:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FRAppDelegate 0xa18bf20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key __mapView.'
my code is as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[FRViewController alloc] initWithNibName:@"FRViewController" bundle:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void) orientationChanged:(NSNotification *)note
{
UIDevice * device = note.object;
switch(device.orientation)
{
case UIDeviceOrientationPortrait:
case UIDeviceOrientationPortraitUpsideDown:
{
NSArray *nibArray=[[NSBundle mainBundle] loadNibNamed:@"FRViewController" owner:self options:nil];
[self.viewController setView:[nibArray objectAtIndex:0]];
NSLog(@"device orientation comes to portrait mode ");
/* start special animation */
}
break;
case UIDeviceOrientationLandscapeRight:
case UIDeviceOrientationLandscapeLeft:
{
NSArray *nibArray=[[NSBundle mainBundle] loadNibNamed:@"FRViewControllerLand" owner:self options:nil];
[self.viewController setView:[nibArray objectAtIndex:0]];
NSLog(@"device orientatino comes to Landscape mode");
/* start special animation */
}
break;
default:
break;
};
}