Ios 取消UIPrintInteractionController
我正在使用UIPrintInteractionController从rect演示它Ios 取消UIPrintInteractionController,ios,ipad,uiprintinteractioncntrler,Ios,Ipad,Uiprintinteractioncntrler,我正在使用UIPrintInteractionController从rect演示它 UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController]; // than set printing settings ... if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) [controller pre
UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];
// than set printing settings
...
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
[controller presentFromRect:rect inView:view animated:YES completionHandler:completionHandler];
然后我将页数设置为>1并选择一台打印机。
在我打电话之前
[控制器已设置动画:已设置动画]
根据Xcode文档:当打印选项显示在图纸中或从矩形设置动画,并且用户更改设备的方向时,您应该取消打印选项
当我在旋转后显示UIPrintInteractionController时,打印副本的数量将设置回初始视图中的1,而打印机仍处于选中状态。
UIPrintInfo的Ivar\u副本是私有的,因此我无法在轮换期间获取和存储它
如何恢复轮换后的打印页数?很抱歉,这似乎是一个明显的问题,但您是否已将其称为代表
UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];
controller.delegate = self;
如果我理解正确,您可以设置和设置@copies of UIPrintInfo,您真正需要的是如何在方向更改前后运行代码: 迅速:
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
//code goes here to run before orientation change
coordinator.animate(alongsideTransition: nil, completion: {
_ in
//code goes here to run after orientation change
})
}
为什么要在轮换时取消它?@NeverBe,因为苹果在UIPrintInteractionController类的dismissAnimated:method描述中建议这样做。如果打印选项显示在图纸中或从矩形设置动画,并且用户更改了设备的方向,则应取消打印选项。一旦新方向生效,你应该再次展示打印选项。这里有一个答案。你有没有找到答案?@RyanPoolos仍然没有,你有什么想法吗?请进一步解释。你做了什么?为什么?代码中的关键行在哪里?
[printInfo setValue:[NSNumber numberWithInteger:numberFile] forKey:@"copies"]
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
//code goes here to run before orientation change
coordinator.animate(alongsideTransition: nil, completion: {
_ in
//code goes here to run after orientation change
})
}