UIPrintInteractionController不在iPad中显示

我正尝试从iPhone和iPad上运行的应用程序进行打印。 打印的iPhone部分没有问题。 但是,每当我点击打印button时,我都没有popup来让我select打印机并发送作业。

这个被称为的视图是一个导航控制器中的常规UIView,如果它有任何的方向。

通过IBAction调用它的button是分段控件的一部分,因为这似乎是除了导航栏中的后退button之外还有三个button的最佳方式。 我不认为这是button,因为如我所说,它在iPhone版本。

我已经证实,至less它认为它正在呈现。 我生成的图片的高度,宽度和原点,但我看不到它。 任何帮助将是了不起的,因为这是这个应用程序的最后一块难题。

谢谢!

- (void)printStory { UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; pic.delegate = self; UIPrintInfo *printInfo = [UIPrintInfo printInfo]; printInfo.outputType = UIPrintInfoOutputGeneral; printInfo.jobName = @"My Great Prompt"; pic.printInfo = printInfo; NSString *msgBody = [NSString stringWithFormat:@"%@%@%@", self.summaryLabel.text, @"\n\n", self.storyEditorTextView.text]; UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:msgBody]; textFormatter.startPage = 0; textFormatter.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0); // 1 inch margins textFormatter.maximumContentWidth = 6 * 72.0; pic.printFormatter = textFormatter; pic.showsPageRange = YES; void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { if (!completed && error) { NSLog(@"Printing could not complete because of error: %@", error); } }; if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { [pic presentFromRect:self.view.frame inView:self.view animated:YES completionHandler:completionHandler]; } else { [pic presentAnimated:YES completionHandler:completionHandler]; } } 

你需要通过一个较小的rect 。 您无法传入视图控制器视图的rect 。 popup窗口显示在传入的边界的周围。 如果矩形填充屏幕,则popup屏幕将显示在屏幕之外。 矩形应该是一个相对较小的东西,像一个button或其他小视图的矩形,这样popover的指针可以触及矩形的边缘,其余的popup可以放在屏幕上。

请将下面的代码移到.h文件中。

 UIPrintInteractionController *pic; 

因为当方法完成时,pic对象将被释放,所以可能会导致问题。

你所传递的信息应该是你所使用的button或段的位置。

希望这会帮助你。