0

HIDキーボードのキー押下を使用してスクリーンショットを撮るのに役立つアプリを作成したいのですが、HIDキーボードのキー押下を検出する方法がわかりませんでした。よろしくお願いします。

4

2 に答える 2

0

私はその特別なキーボードについて知りませんが、このコードを使用すると、アプリケーションからスクリーショットを撮ることができます。このコードをボタンアクションに入れて、機能していることを確認できますが、キーボードについてはわかりません。

UIGraphicsBeginImageContext(self.window.bounds.size);
[self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData * data = UIImagePNGRepresentation(image);
[data writeToFile:@"foo.png" atomically:YES];

2011年4月の更新:Retinaディスプレイの場合、最初の行を次のように変更します。

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(self.window.bounds.size);
于 2013-02-05T11:55:55.403 に答える
0

使用できますKeyboard notification

#pragma mark - Keyboard notification
- (void)registerForKeyboardNotifications
{    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillBeShown:)
                                                 name:UIKeyboardWillShowNotification object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillBeHidden:)
                                                 name:UIKeyboardWillHideNotification object:nil];
}

-(void)keyboardWillBeShown:(NSNotification*)aNotification
{

}
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
{

}
于 2013-02-05T12:33:55.910 に答える