So I figured out how to use UIPrintInteractionController with a custom UIPrintPageRenderer (subclass). That is working fine but now I want to print from the print button shown by UIActivityViewController. This part is confusing and the documentation is rather lacking. 
I expected to see the print options (as with UIPrintInteractionController), but I only see the completionHandler result of UIActivityViewController. Nothing is printed.
Am I suppose to show the UIPrintInteractionController myself in the completionHandler?
But the API says "Upon the completion of an activity, or the dismissal of the activity view controller, the view controllers completion block is executed." So this should run after printing has completed.
And also if I have to show the printing options myself, then why don't I have to do the same thing for mail? I get the "compose mail view" when selecting mail from the UIActivityViewController.
Also the UIActivityViewController only shows the print icon if I return a UISimpleTextPrintFormatter in activityViewControllerPlaceholderItem: but I want to use my own pageRenderer.
and the
subclass
I expected to see the print options (as with UIPrintInteractionController), but I only see the completionHandler result of UIActivityViewController. Nothing is printed.
Am I suppose to show the UIPrintInteractionController myself in the completionHandler?
But the API says "Upon the completion of an activity, or the dismissal of the activity view controller, the view controllers completion block is executed." So this should run after printing has completed.
And also if I have to show the printing options myself, then why don't I have to do the same thing for mail? I get the "compose mail view" when selecting mail from the UIActivityViewController.
Also the UIActivityViewController only shows the print icon if I return a UISimpleTextPrintFormatter in activityViewControllerPlaceholderItem: but I want to use my own pageRenderer.
Code:
UIActivityViewController *activityView = [[UIActivityViewController alloc] initWithActivityItems:@[dummy<MyActivityItem>Object]
applicationActivities:nil];
[activityView setCompletionHandler:^(NSString *activityType, BOOL completed){
NSLog(@"complete");
}];
[self presentViewController:activityView
animated:YES
completion:nil];
and the
Code:
MyActivityItem : UIActivityItemProvider <UIActivityItemSource>
Code:
-(id) activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController
{
NSString *textToShare = @"self.note.note";
//not that this is printing anyway, but I also want to use my own printPageRenderer
UISimpleTextPrintFormatter *printData = [[UISimpleTextPrintFormatter alloc]
initWithText:textToShare];
return printData; //now the print item shows up
return [[UIImage alloc] init]; //
}
-(id) item
{
NSLog(@"prepare item");
//do stuff here to prepare the actual item
NSLog(@"item ready");
return @"activity item";
}