Descarte de UIPrintInteractionController

Estoy usando UIPrintInteractionController presentándolo de rect.

 UIPrintInteractionController *controller = [UIPrintInteractionController shanetworkingPrintController]; // than set printing settings ... if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) [controller presentFromRect:rect inView:view animated:YES completionHandler:completionHandler]; 

Que establezca el número de páginas (> 1) y select una impresora. Antes de la rotation de dispositivos llamo

[controller dismissAnimated:animated];

según la documentation de Xcode: You should dismiss the printing options when they are presented in a sheet or animated from a rectangle and the user changes the orientation of the device.

Cuando presento UIPrintInteractionController después de la rotation, el número de copys de printing se vuelve a establecer en 1 (como en la vista inicial), mientras que la impresora permanece seleccionada. Ivar _copies de UIPrintInfo es privado, así que no puedo getlo y almacenar durante la rotation.

¿Cómo puedo restaurar el número de páginas de printing después de la rotation?

Lo sentimos, puede parecer una pregunta obvia pero ¿lo llamaste delegado?

 UIPrintInteractionController *controller = [UIPrintInteractionController shanetworkingPrintController]; controller.delegate = self; 
 [printInfo setValue:[NSNumber numberWithInteger:numberFile] forKey:@"copies"] 

Puede configurar y configurar @"copies" de UIPrintInfo

Si te entiendo correctamente, lo que realmente necesitas es cómo ejecutar el código antes y después de los cambios de orientación:

En swift:

 override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) //code goes here to run before orientation change coordinator.animate(alongsideTransition: nil, completion: { _ in //code goes here to run after orientation change }) } 

Obj C docs:

 - (void)printImage:(id)sender { // Obtain the shanetworking UIPrintInteractionController UIPrintInteractionController *controller = [UIPrintInteractionController shanetworkingPrintController]; if(!controller){ NSLog(@"Couldn't get shanetworking UIPrintInteractionController!"); return; } // We need a completion handler block for printing. UIPrintInteractionCompletionHandler completionHandler = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { if(completed && error) NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code); }; // Obtain a printInfo so that we can set our printing defaults. for(int i=0;i<[paths count];i++) { NSString *strFilePath = [paths objectAtIndex:i]; NSLog(@"@ strFilePath is %@", strFilePath); NSData *data = [NSData dataWithContentsOfFile:strFilePath]; if(data) { image = [UIImage imageWithData:data]; // [arrayOfImages addObject:image]; NSLog(@"@ image is %@", image); UIPrintInfo *printInfo = [UIPrintInfo printInfo]; // This application prints photos. UIKit will pick a paper size and print // quality appropriate for this content type. printInfo.outputType = UIPrintInfoOutputPhoto; // The path to the image may or may not be a good name for our print job printInfo.jobName = @"PNg"; NSLog(@"@ imageURL is %@", printInfo.jobName); // printInfo.jobName if(!controller.printingItems && image.size.width > image.size.height) printInfo.orientation = UIPrintInfoOrientationLandscape; // Use this printInfo for this print job. controller.printInfo = printInfo; controller.printingItems = nil; } } #if DIRECT_SUBMISSION // Use the URL of the image asset. if(self.imageURL && [UIPrintInteractionController canPrintURL:self.imageURL]) controller.printingItem = self.imageURL; #endif // If we aren't doing direct submission of the image or for some reason we don't // have an ALAsset or URL for our image, we'll draw it instead. if(!controller.printingItems){ // Create an instance of our PrintPhotoPageRenderer class for use as the // printPageRenderer for the print job. PrintPhotoPageRenderer *pageRenderer = [[PrintPhotoPageRenderer alloc]init]; pageRenderer.imageToPrint = image; controller.printPageRenderer = pageRenderer; [pageRenderer release]; } if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [controller presentFromBarButtonItem:self.printButton animated:YES completionHandler:completionHandler]; // iPad }else [controller presentAnimated:YES completionHandler:completionHandler]; // iPhone }