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>'

Code Block
- (UIViewController *)printInteractionControllerParentViewController: (UIPrintInteractionController *)printInteractionController {
return [CXSCommon getParentController_iPhone];
}

Code Block
- (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];
}
}


Accepted Reply

We're also experiencing this issue and can confirm that it's still an issue with iOS 14 Beta 5. FB8256200 has been filed.

Replies

We're also experiencing this issue and can confirm that it's still an issue with iOS 14 Beta 5. FB8256200 has been filed.
Any Update on above reported issue (Ticket No : FB8256200).
This issue has been resolved by commenting the following code :

Code Block
  UITableView *tableView = [UITableView appearance];
  [tableView setSectionIndexColor:[UIColor grayColor]];
  if ([[UITableView class ] instancesRespondToSelector:@selector(setSectionIndexBackgroundColor:)]) {
    [tableView setSectionIndexBackgroundColor:[UIColor clearColor]];
  }
  [tableView setTableFooterView:[UIView new]];
  [tableView setTableHeaderView:[UIView new]];


I know this is strange, But it solved in my case.

I have the same question, but i don't know where should i add these code?
Hi Carlddy

Please remove UIView allocation from TableFooterView and TableHeaderView in UITableView appearance methods