I've implemented AirPrinting from my app but I'm facing a strange issue. Whenever the print dialog appears, there are no Cancel or Done/Print buttons displayed, as shown in the following image.
The code I'm using is as follows:
if ([UIPrintInteractionController canPrintURL:pdfUrl]) {
UIPrintInfo *aPrintInfo = [UIPrintInfo printInfo];
aPrintInfo.outputType = UIPrintInfoOutputGeneral;
aPrintInfo.jobName = [NSString stringWithFormat:@"%@-PRINT",[[NSUserDefaults standardUserDefaults] stringForKey:@"Kiosk ID"]];
UIPrintInteractionController *aPrintController = [UIPrintInteractionController sharedPrintController];
aPrintController.showsNumberOfCopies=YES;
aPrintController.showsPaperSelectionForLoadedPapers=YES;
aPrintController.printingItem = pdfUrl;
aPrintController.printInfo = aPrintInfo;
[aPrintController presentAnimated:YES completionHandler:NULL];
}
Does anyone have experience with this problem and know how to rectify? What's really odd is that the actions for these hidden buttons still work; so if I tap where the print button should be, it'll print and likewise I can close the dialog by tapping the top left where the Cancel button should be.
Cheers!
p.s using latest version of IOS 11, issue occurs in simulator and on device.
[Edit] I've just now tested a print example from Apple found at https://developer.apple.com/library/content/samplecode/PrintBanner/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013422-Intro-DontLinkElementID_2
and although the code to bring up the AirPrint dialog are very similar (more-so after I tweaked a few bits of my code) the demo code worked as expected (buttons visible) while my code still does not. Very confusing.
[Edit 2] Using the code sample above in a fresh project works as expected too. Yet, in my full app, it does not. Does anyone have experience as to why that my be? Are system dialogs affected by the size of the app perhaps? Doesn't seem likely, but there is definitely something awry with my app using this code that isn't obvious.
[Edit 3] I enhanced the fresh project by incrementally introducing the same elements from my main project, going as far as bringing in the same Pods and setting up the same UI structure, and adding UIImage elements. It did not have the exact same number of views, and those were not doing the same things as my main project, but the memory usage was similar. And yet still, it worked. Are workspace corruptions a thing in Xcode, something behind the scenes not represented in any UI that might explain this?
[Edit 4] I just created a completely new project, reinstalled all the pods, then moved my source files from my original project to the new project. Quell surprise, the issue still remains in the new project.
[Edit 5] Solved! I finally found the issue thanks in part to the tip from the accepted answer below. It was due to having a global tint colour set to Clear, but also having individual Views within each controller also setting the tint colour to clear. This affected the dialog being shown and as such the buttons were invisible. Once I changed the Views to have an actual colour for the Tint property the print dialog buttons were once again visible.
There is no direct issue with UIPrintInteractionController code. As you mention click of done and cancel buttons are working as expected. The only problem is visibility of buttons.
Try changing navigation bar tint color before presenting print controller.
self.navigationBar.barStyle = UIBarStyle.Black
self.navigationBar.tintColor = .black
Note:- I don't have your code. This is only one of the problems and solution related to your issue.