有没有办法指定笔尖名称,以便应用程序在方向发生变化时自动拾取横向或纵向的相应笔尖。就像 iphone 4 和 iphone 5 有 Default@2x.png 和 Default-568h@2x.png 之类的那。如果不是?,我正在尝试在应用程序委托方法中添加观察者以更改方向,它工作正常,但是在orientationChanged方法中更改笔尖时会导致应用程序崩溃并产生错误,如下所示:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<FRAppDelegate 0xa18bf20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key __mapView.'
我的代码如下:
- (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;
};
}