向きが変わったときにアプリケーションが横向きまたは縦向きに対応するペン先を自動的にピックアップするようにペン先名を指定する方法はありますか?そうでない場合、アプリのデリゲート メソッドで方向の変更のために addObserver を試行していますが、正常に動作していますが、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;
};
}