4
目前我正在爲iPhones和iPads的Paint應用程序工作。我想要打印屏幕的當前屏幕顯示(繪圖)。在這種情況下,任何機構可以幫助我嗎?iOs打印當前屏幕
這是到目前爲止,我已經使用的代碼,
-(void)printImage {
NSString *path = [[NSBundle mainBundle] pathForResource:@"micky" ofType:@"png"];
NSData *dataFromPath = [NSData dataWithContentsOfFile:path];
UIPrintInteractionController *pCon = [UIPrintInteractionController sharedPrintController];
if(pCon && [UIPrintInteractionController canPrintData:dataFromPath]) {
pCon.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = [path lastPathComponent];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
pCon.printInfo = printInfo;
pCon.showsPageRange = YES;
pCon.printingItem = dataFromPath;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"Unsuccessfull %@ error%u", error.domain, error.code);
}
};
[pCon presentAnimated:YES completionHandler:completionHandler];
}
}
同樣,所有我想知道的是,我應該能夠打印當前窗口(繪畫,屏幕),而不是形象米奇。 PNG(如代碼)
感謝名單這就是工作像魅力。我想多加強一點。如果我想在當前屏幕中獲取特定視圖的屏幕截圖,那我該怎麼做? – BigAppleBump 2012-02-17 03:01:30
用你想抓取的任何視圖替換「self.view」的出現次數。請將此答案標記爲已接受:) – samvermette 2012-02-17 04:51:49
是的。非常感謝你 – BigAppleBump 2012-02-17 05:33:17