Post

Replies

Boosts

Views

Activity

UIPrintInteractionController crashed in iOS 14
When presented in a standalone single view application the following code works a treat. But when I try to load the same code on UISplitViewController the application crashed,But this code works like a charm in iOS 13 application.But In iOS 14 it is going to crash and following exception occur: Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UIPrintPreviewViewController: 0x10394fa00> should have parent view controller:<CXSTransactionSelectionViewController: 0x10389e400> but actual parent is:<UIPrintPanelTableViewController: 0x103808200>' (UIViewController *)printInteractionControllerParentViewController: (UIPrintInteractionController *)printInteractionController { return [CXSCommon getParentController_iPhone]; } (void)Print { UIPrintInteractionController *controller = [UIPrintInteractionController	 sharedPrintController]; 		 if(!controller){ 				 NSLog(@"Couldn't get shared UIPrintInteractionController!"); 				 return; 		 } 		 		 UIPrintInteractionCompletionHandler completionHandler = 		 ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { 				 if(!completed && error){ 						 NSLog(@"FAILED! due to error in domain %@ with error code %ld", error.domain, (long)error.code); 				 } 				 else 				 { 						 NSLog(@"complete"); 				 } 		 }; 		 UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; 		 pic.delegate						= self; 		 UIPrintInfo *printInfo	= [UIPrintInfo printInfo]; 		 printInfo.outputType		= UIPrintInfoOutputGeneral; 		 printInfo.jobName			 = @"My Job"; 		 printInfo.duplex				= UIPrintInfoDuplexLongEdge; 		 pic.printInfo					 = printInfo; 		 		 UIMarkupTextPrintFormatter *textPrint = [[UIMarkupTextPrintFormatter alloc] initWithMarkupText:[NSString stringWithFormat:@"<!DOCTYPE html><html><body><p><h1>Hello World</h1></p><p><h2>Hello World</h2></p><p><h3>Hello World</h3></p><p><h4>Hello World</h4></p><p><h5>Hello World</h5></p><p><h6>Hello World</h6></p></body></html>"]]; 		 pic.printFormatter = textPrint; 		 if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 				// [controller presentFromBarButtonItem:self.addressButton animated:YES completionHandler:completionHandler]; 				 				 [controller presentAnimated:YES completionHandler:completionHandler]; 		 } 		 else { 				 [controller presentAnimated:YES completionHandler:completionHandler]; 		 } }
5
0
2k
Jul ’20