Amiram Stark
Amiram Stark

Reputation: 2208

UIPrintInteractionController presentAnimated - slow and hangs the device?

I am using UIPrintInteractionController presentAnimated to present a print dialog from a button in a UIActionSheet.

As soon as I touch the button, there are ~10 seconds in which the device does nothing visible and the action sheet remains on the screen. Then the action sheet is removed and the print dialog is displayed.

If I try to show an activity indicator BEFORE I call presentAnimated, it doesn't show until these ~10 seconds are over, and then it starts showing briefly until the print dialog covers it.

Is there anything that I can do to tell the user that something is going on and the device did not hang?

Upvotes: 0

Views: 1072

Answers (3)

Mohsin Qureshi
Mohsin Qureshi

Reputation: 1213

//dataWithContentsOfURL is blocking call, it should be called like: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ pc.printingItem = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"urlString"]]; });

It will present the UIPrintInteractionController immediately.

Upvotes: 1

hayrom
hayrom

Reputation: 21

Late answer, but might help someone: Besides informing the user that it takes long, you can also speedup the process by setting the property showsPageRange of the UIPrintInteractionController instance to NO. In my case this reduced the time to popup the print dialog from 8 seconds to 0.7 seconds.

Upvotes: 2

Amiram Stark
Amiram Stark

Reputation: 2208

Well, I still don't know what's causing this, but there's an obvious workaround which I somehow missed... call presentAnimated after a short delay to allow the action sheet to be dismissed and the activity indicator to start rolling.

Upvotes: 0

Related Questions