Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 8打印交互控制器在iPad上的高度为0_Ios_Objective C_Ipad_Ios8_Airprint - Fatal编程技术网

iOS 8打印交互控制器在iPad上的高度为0

iOS 8打印交互控制器在iPad上的高度为0,ios,objective-c,ipad,ios8,airprint,Ios,Objective C,Ipad,Ios8,Airprint,我试图提供一个UIPrintInteractionController实例,以使用AirPrint打印图像。起初似乎什么都没有发生,但在委托方法printInteractionControllerdPresentPrinterOptions:中,我使用self.presentedViewController获取有关假定的“presented”打印交互控制器的信息。原来它的宽度是19.000,高度是0.000。。。在viewcontroller实际呈现之前,似乎没有办法访问它,因为它在框架中都是自

我试图提供一个UIPrintInteractionController实例,以使用AirPrint打印图像。起初似乎什么都没有发生,但在委托方法
printInteractionControllerdPresentPrinterOptions:
中,我使用
self.presentedViewController
获取有关假定的“presented”打印交互控制器的信息。原来它的宽度是19.000,高度是0.000。。。在viewcontroller实际呈现之前,似乎没有办法访问它,因为它在框架中都是自动生成的,而且我还无法成功修改它的帧后呈现。其他人是否遇到此问题和/或找到解决方法

- (void)printBadgeImage:(UIImage *)image {

    UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];

    UIPrintInfo *printInfo = [UIPrintInfo printInfo];
    printInfo.outputType = UIPrintInfoOutputGeneral;
    printInfo.jobName = BADGE_PRINT_JOB;
    printInfo.duplex = UIPrintInfoDuplexLongEdge;
    pic.printInfo = printInfo;
    pic.printingItem = image;
    pic.delegate = self;

    UIPrintInteractionCompletionHandler completionHandler =
    ^(UIPrintInteractionController *printController,
      BOOL completed,
      NSError *error) {

        if (completed) {

            NSLog(@"Print job completed");

        } else if (!completed && error) {

            NSLog(@"Print job error");
            NSString *errorString = [NSString stringWithFormat:@"An error occured while printing: %@", error];
            UIAlertView *alert = [[DOSimpleAlertView alloc] initWithTitle:@"Error"
                                                                  message:errorString];

            [alert show];

        } else {

           NSLog(@"Print job incomplete without error");
        }
    };

    [pic presentFromRect:self.view.frame
                  inView:self.view
                animated:YES
       completionHandler:completionHandler];

}

- (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController {

    NSLog(@"Did present");
    // following printed <UIPrintInteractionController: 0x145d1a30>
    NSLog(@"The Print Interaction Controller: %@", printInteractionController);
    // following printed <UINavigationController: 0x145d3840>
    NSLog(@"The presented view: %@", self.presentedViewController);
    UIViewController *presented = self.presentedViewController;
    // following printed 19.000000
    NSLog(@"Presented view width: %f", presented.view.frame.size.width);
    // following printed 0.000000
    NSLog(@"Presented view height: %f", presented.view.frame.size.height);
    // following printed 0.000000
    NSLog(@"Presented view x: %f", presented.view.frame.origin.x);
    // following printed 0.000000
    NSLog(@"Presented view y: %f", presented.view.frame.origin.y);
-(无效)printBadgeImage:(UIImage*)图像{
UIPrintInteractionController*pic=[UIPrintInteractionController sharedPrintController];
UIPrintInfo*printInfo=[UIPrintInfo printInfo];
printInfo.outputType=UIPrintInfoOutputGeneral;
printInfo.jobName=BADGE\u PRINT\u JOB;
printInfo.duplex=UIPrintInfoDuplexLongEdge;
pic.printInfo=printInfo;
pic.printing项目=图像;
pic.delegate=self;
UIPrintInteractionCompletionHandler completionHandler=
^(UIPrintInteractionController*printController,
布尔完成,
N错误*错误){
如果(已完成){
NSLog(@“打印作业已完成”);
}否则,如果(!已完成&错误){
NSLog(@“打印作业错误”);
NSString*errorString=[NSString stringWithFormat:@“打印时出错:%@”,错误];
UIAlertView*警报=[[DOSimpleAlertView alloc]initWithTitle:@“错误”
消息:errorString];
[警报显示];
}否则{
NSLog(@“打印作业未完成,无错误”);
}
};
[pic presentFromRect:self.view.frame
查看:自我观点
动画:是的
completionHandler:completionHandler];
}
-(void)PrintInteractionControllerdPresentPrinterOptions:(UIPrintInteractionController*)printInteractionController{
NSLog(@“确实存在”);
//下列印刷品
NSLog(@“打印交互控制器:%@”,printInteractionController);
//下列印刷品
NSLog(@“呈现视图:%@”,self.presentedViewController);
UIViewController*presented=self.presentedViewController;
//以下为打印的19.000000
NSLog(@“呈现视图宽度:%f”,呈现.view.frame.size.width);
//以下打印0.000000
NSLog(@“呈现视图高度:%f”,呈现.view.frame.size.height);
//以下打印0.000000
NSLog(@“呈现视图x:%f”,Presented.view.frame.origin.x);
//以下打印0.000000
NSLog(@“呈现视图y:%f”,呈现.view.frame.origin.y);

我有一个可以打印图像的应用程序,但是我已经很久没有看代码了。但是这里是简介,希望能有所帮助

NSData *moneyData = UIImageJPEGRepresentation(image, 1.0);
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
if(pic && [UIPrintInteractionController canPrintData: moneyData] ) {

    pic.delegate = self;

    UIPrintInfo *printInfo = [UIPrintInfo printInfo];
    printInfo.outputType = UIPrintInfoOutputGeneral;
    printInfo.jobName = @"MONEY";
    printInfo.duplex = UIPrintInfoDuplexLongEdge;
    pic.printInfo = printInfo;
    pic.showsPageRange = YES;
    pic.printingItem = moneyData;

    [pic presentFromBarButtonItem:self.printButton animated:YES completionHandler:nil];
}
如果我没记错的话,你展示它的方式有些特别。你可能想试试我的按钮