UIPrintInteractionController无法在iPad中显示 [英] UIPrintInteractionController not displaying in iPad

查看:133
本文介绍了UIPrintInteractionController无法在iPad中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从iPhone和iPad上运行的应用程序进行打印。 iPhone部分打印没有问题。但是,每当我点击打印按钮时,我都没有弹出窗口允许我选择打印机并发送作业。

I'm trying to print from an app that runs on both iPhone and iPad. There's no problem with the iPhone part of the printing. However, whenever I hit the print button, I do not get the pop-up to allow me to select the printer and send the job.

这是从如果有任何方位,它是导航控制器中的常规UIView。

The view this is called from is a regular UIView in a navigation controller if that has any bearing.

通过IBAction调用它的按钮是分段控件的一部分,因为它似乎是最好的我可以在导航栏中的后退按钮旁边获得三个按钮。我不认为这是按钮,因为正如我所说,它适用于iPhone版本。

The button that calls it via IBAction is part of the segmented control, since that seemed to be the best way for me to get three buttons besides the back button in the nav bar. I don't think it's the button because as I said, it works in the iPhone version.

我已经确认它至少认为它正在呈现。我为pic生成了高度,宽度和原点,但我看不到它。任何帮助都会很棒,因为这是这个应用程序的最后一块拼图。

I have verified that it at least thinks it's presenting. I generates and height, width and origin for the pic, but I can't see it. Any help would be terrific as this is the last piece of the puzzle for this app.

谢谢!

- (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 。弹出窗口显示在传入矩形的周边。如果rect填充屏幕,弹出窗口将显示在屏幕外。 rect应该是一个相对较小的东西,如按钮的矩形或其他小视图,这样popover的指针可以触摸rect的边缘,其余的popover可以适合屏幕。

You need to pass in a smaller rect. You can't pass in the rect of the view controller's view. The popover is displayed around the perimeter of the passed in rect. If the rect fills the screen, the popover is displayed off of the screen. The rect should be something relatively small like the rect of a button or other small view such that the popover's pointer can touch the edge of the rect and the rest of the popover can fit on the screen.

这篇关于UIPrintInteractionController无法在iPad中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆