简体   繁体   English

我们如何使用HID键盘按键拍摄iphone / ipad设备的屏幕截图?

[英]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.

相关问题 iPhone和iPad,播放视频时截图 - iPhone and iPad, take screenshot with video playing 我们可以将ipad设备的本机键盘隐藏在文本字段上吗? - can we hide the native keyboard of ipad device on focus on textfield 在开发过程中,我们可以在iPad设备上运行iPhone应用程序吗? - Can we run an iPhone app on iPad device during development? 如何以编程方式拍摄iPhone的屏幕截图? - how to take a screenshot of the iPhone programmatically? 如何在不使用服务器的情况下将文件从一部 iphone 传输到另一部 iphone/ipad 设备 - how can i transfer a file from one iphone to another iphone/ipad device without using a server 当用户按下Next(返回)按钮时,在iPhone或iPad的键盘上 - On the keyboard either iphone or ipad, when the user press the Next(Return) button 我们可以使用gamecenter在iPhone和iPad之间在线玩游戏吗? - Can we play a game online between iPhone & iPad using gamecenter? 如何使用JavaScript在iPhone / iPad中检测屏幕键盘的高度 - How to detect the height of onscreen keyboard in iphone/ipad using javascript 如何在iPhone中使用相机预览拍摄屏幕截图? - How to take screenshot with camera preview in iPhone? 如何使用CCLayer拍摄设备相机的屏幕截图 - How to take screenshot of device camera with the CCLayer on it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM