- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
UIPrintInteractionControllerDelegate
的文档似乎建议您可以使用 printInteractionControllerParentViewController:
返回可用于推送 的
到标准的 UIViewController
>UIPrintInteractionControllerUINavigationController
堆栈中,其方式与在 iOS 的 Pages.app 中完成的方式大致相同,但尽管我尝试这样做,但我还是设法做到了将一个空的 UIViewController
对象推送到堆栈,除此之外别无其他。
有没有人知道如何做到这一点,或者是否可以做到这一点?
(明确一点,我对任何使用私有(private) API 等的方法不感兴趣。)
最佳答案
我在尝试让打印机选项出现在类似于 Pages 的 NavigationController 中时遇到了同样的问题。
重要的一点是实现 UIPrintInteractionControllerDelegate 的 printInteractionControllerParentViewController 以返回 NavigationController。
该方法只会从 UIPrintInteractionController 的现有方法中调用。
Apple docs on UIPrintInteractionControllerDelegate
一些示例代码:
// Just some code to return a UIPrintInteractionController
// Important to set delegate to self
- (UIPrintInteractionController *)printContent {
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
if (pic && [UIPrintInteractionController canPrintURL:[self fileToPrint]]) {
pic.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"OutputFile";
printInfo.duplex = UIPrintInfoDuplexLongEdge;
pic.printInfo = printInfo;
pic.showsPageRange = YES;
pic.printingItem = self.fileToPrint;
}
return pic;
}
实现委托(delegate)的 printInteractionControllerParentViewController 方法。
// Implement the delegate method simply to return navigationController
- (UIViewController *)printInteractionControllerParentViewController:(UIPrintInteractionController *)printInteractionController{
return self.navigationController;
}
仅当您运行 UIPrintInterfaceController 的 Present 方法时才会调用委托(delegate),例如presentFromRect:
// Need to call a present method to invoke the delegate method
[[self printContent] presentFromRect:[self.view frame] inView:self.view animated:NO completionHandler:completionHandler];
关于objective-c - 将 UIPrintInteractionController 推送到 UINavigationController 堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10819880/
我是一名优秀的程序员,十分优秀!