【发布时间】:2015-06-19 11:20:53
【问题描述】:
在我的应用中,可以打印不同尺寸的照片。这工作正常,但在 iOS 8 中,即使打印对话框显示例如 5"x7",纸张大小也始终为 letter/A4。如果用户再次选择纸张尺寸,则纸张尺寸更改为例如5"x7"。
有人遇到同样的问题吗?
有解决办法吗?
代码如下:
- (UIPrintPaper *)printInteractionController:(UIPrintInteractionController *)printInteractionController choosePaper:(NSArray *)paperList
{
CGSize PageSize = ((PPPage *)[document.pages objectAtIndex:0]).paperSize;
if (PageSize.width > PageSize.height) {
float w = PageSize.width;
PageSize.width = PageSize.height;
PageSize.height = w;
}
NSLog(@"printInteractionController:choosePaper: Needed Pagesize = (%.1f,%.1f)",PageSize.width,PageSize.height);
UIPrintPaper *retPaper = [UIPrintPaper bestPaperForPageSize:PageSize withPapersFromArray:paperList];
NSLog(@"printInteractionController:choosePaper: chosen UIPrintPaper = (%.1f,%.1f)",retPaper.paperSize.width,retPaper.paperSize.height);
return retPaper;
}
还有日志输出:
2015-06-19 12:22:53.474 PhotoPrint[5955:1225053] printInteractionController:choosePaper: 需要的页面大小 = (288.0,432.0) 2015-06-19 12:22:54.118 PhotoPrint[5955:1225053] printInteractionController:choosePaper: 选择 UIPrintPaper = (612.0,792.0) 2015-06-19 12:22:54.118 PhotoPrint[5955:1225053]-[PKPaperListmatchedPaper:preferBorderless:withDuplexMode:didMatch:] paperToMatch=result=matchType=0 2015-06-19 12:23:06.351 PhotoPrint[5955:1225053]
--> 选择了错误的纸张尺寸字母!
现在再次选择纸张:
printInteractionController:choosePaper: 需要的页面大小 = (288.0,432.0) 2015-06-19 12:23:14.860 PhotoPrint[5955:1225053] printInteractionController:choosePaper: 选择 UIPrintPaper = (360.0,504.0) 2015-06-19 12:23:14.860 PhotoPrint[5955:1225053] -[PKPaperListmatchedPaper:preferBorderless:withDuplexMode:didMatch:] paperToMatch= result= matchType=0
--> 这次是正确的纸张尺寸。
【问题讨论】:
-
最初的问题是关于使用 AirPrint 打印的。我认为标题在编辑后可能会令人困惑,所以我尝试改写我的问题:在 iOS 上使用 AirPrint 打印时如何选择特定的纸张尺寸?
-
如果标题现在令人困惑:为什么不简单地更改它并使其不混乱?!?!