[英]How can we take the screenshot of iphone/ipad device using HID keyboard key press?
我想创建一个可以帮助我们使用HID键盘按键进行屏幕截图的应用程序,但是我不知道如何检测HID键盘按键。请事先帮助我,谢谢
i dont know about that special keyboard but using of this code you can take a scree shot from your application. 我不知道那个特殊的键盘,但是使用此代码,您可以从应用程序中抓弹。 You can put this code in button action and check it's working but about your keyboard i have no idea. 您可以将此代码置于按钮操作中并检查其是否正常工作,但是关于您的键盘我一无所知。
UIGraphicsBeginImageContext(self.window.bounds.size);
[self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData * data = UIImagePNGRepresentation(image);
[data writeToFile:@"foo.png" atomically:YES];
UPDATE April 2011: for retina display, change the first line into this: 2011年4月更新:对于视网膜显示,将第一行更改为:
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(self.window.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(self.window.bounds.size);
You can use Keyboard notification
您可以使用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
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.