objective-c - 将 UIPrintInteractionController 推送到 UINavigationController 堆栈
<p><p><code>UIPrintInteractionControllerDelegate</code> 的文档似乎建议您可以使用 <code>printInteractionControllerParentViewController:</code> 返回可用于推送 <code> 的 <code>UIViewController</code> >UIPrintInteractionController</code> 到标准 <code>UINavigationController</code> 堆栈中,其方式与在 iOS 的 Pages.app 中完成的方式大致相同,但尽管我尝试这样做,但我已经设法做到了是将一个空的 <code>UIViewController</code> 对象推送到堆栈,仅此而已。</p>
<p>有没有人对如何做到这一点有任何想法,或者是否可以做到?</p>
<p>(为了清楚起见,我对任何使用私有(private) API 等的方法不感兴趣。)</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我在尝试让打印机选项出现在类似于 Pages 的 NavigationController 中时遇到了同样的问题。<br/>重要的是实现 UIPrintInteractionControllerDelegate 的 printInteractionControllerParentViewController 以返回 NavigationController。<br/>
该方法只会从 UIPrintInteractionController 的当前方法调用。<br/>
<a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIPrintInteractionControllerDelegate_Protocol/UIPrintInteractionControllerDelegate_Protocol.pdf" rel="noreferrer noopener nofollow">Apple docs on UIPrintInteractionControllerDelegate</a>
<br/>
<br/>
一些示例代码:</p>
<pre><code>// Just some code to return a UIPrintInteractionController
// Important to set delegate to self
- (UIPrintInteractionController *)printContent {
UIPrintInteractionController *pic = ;
if(pic && ]) {
pic.delegate = self;
UIPrintInfo *printInfo = ;
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"OutputFile";
printInfo.duplex = UIPrintInfoDuplexLongEdge;
pic.printInfo = printInfo;
pic.showsPageRange = YES;
pic.printingItem = self.fileToPrint;
}
return pic;
}
</code></pre>
<p>实现委托(delegate)的printInteractionControllerParentViewController方法。</p>
<pre><code>// Implement the delegate method simply to return navigationController
- (UIViewController *)printInteractionControllerParentViewController:(UIPrintInteractionController *)printInteractionController{
return self.navigationController;
}
</code></pre>
<p>只有在运行 UIPrintInterfaceController 的 Present 方法时才会调用委托(delegate),例如presentFromRect:</p>
<pre><code>// Need to call a present method to invoke the delegate method
[ presentFromRect: inView:self.view animated:NO completionHandler:completionHandler];
</code></pre></p>
<p style="font-size: 20px;">关于objective-c - 将 UIPrintInteractionController 推送到 UINavigationController 堆栈,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/10819880/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/10819880/
</a>
</p>
页:
[1]