Class

UIPrint​Interaction​Controller

The shared instance of the UIPrint​Interaction​Controller class presents a printing user interface and manages the printing of documents, images, and other printable content in iOS.

Overview

UIPrint​Interaction​Controller is the central class for printing in iOS. The shared instance of it represents a print job. A print job includes the content to be printed and information and options related to its printing, such as output type, job name, paper size, and orientation.

UIPrint​Interaction​Controller has four mutually exclusive properties for giving it the content to be printed:

If the shows​Page​Range property is set to true, the number of pages is more than 1, and you assign an object to any of these properties except for the printing​Items property, the printing options include a control that allows users to select a page range.

When users tap a print button on the application’s user interface, a controller object of the application should respond to the action message by obtaining the shared instance of UIPrint​Interaction​Controller and preparing it for the print job. When the application calls one of the present... methods (for example, present(animated:​completion​Handler:​)), UIPrint​Interaction​Controller displays a view containing printing options. This interface is simple, allowing users to select a printer, specify the number of copies and possibly a range of pages, and choose single-sided or double-sided printing (if the printer supports duplex printing). When users make their selections and tap Print, the print job begins.

Symbols

Getting the Shared Controller Instance

class var shared:​ UIPrint​Interaction​Controller

Returns the shared print-interaction controller object.

Determining Printability

class var is​Printing​Available:​ Bool

Returns a Boolean indicating whether the device supports printing.

class func can​Print(Data)

Returns whether UIKit can print the contents of a data object.

class func can​Print(URL)

Returns whether UIKit can print the file referenced by a URL.

class var printable​UTIs:​ Set<String>

Returns a set of the Uniform Type Identifiers for the types of data that UIKit can print.

Providing the Source of Printable Content

var printing​Item:​ Any?

A single ready-to-print object.

var printing​Items:​ [Any]?

An array of ready-to-print objects.

var print​Page​Renderer:​ UIPrint​Page​Renderer?

An object that draws pages of printable content when requested by UIKit.

var print​Formatter:​ UIPrint​Formatter?

An object that lays out the content of pages based on the kind of content.

Presenting the Printing User Interface

func present(animated:​ Bool, completion​Handler:​ UIPrint​Interaction​Completion​Handler? = nil)

Presents the iPhone printing user interface in a sheet that can be animated to slide up from the bottom of the screen.

func present(from:​ UIBar​Button​Item, animated:​ Bool, completion​Handler:​ UIPrint​Interaction​Completion​Handler? = nil)

Presents the iPad printing user interface in a popover view that can be animated from a bar-button item.

func present(from:​ CGRect, in:​ UIView, animated:​ Bool, completion​Handler:​ UIPrint​Interaction​Completion​Handler? = nil)

Presents the iPad printing user interface in a popover view that can be animated from any area in a view.

func dismiss(animated:​ Bool)

Dismisses the printing-options sheet or popover.

Accessing Print-Job Information

var print​Info:​ UIPrint​Info?

An object encapsulating information about the print job.

var print​Paper:​ UIPrint​Paper?

An object representing the paper size and printing area for the print job.

var shows​Number​Of​Copies:​ Bool

A Boolean value that determines whether the printing options include the number of copies.

var shows​Page​Range:​ Bool

A Boolean value that determines whether the printing options include a page-range control.

Deprecated
var shows​Paper​Selection​For​Loaded​Papers:​ Bool

A Boolean value for enabling the paper selection menu.

Assigning the Delegate

var delegate:​ UIPrint​Interaction​Controller​Delegate?

The delegate of the print interaction controller.

Constants

UIPrint​Interaction​Completion​Handler

The type of block callback for responding to the completion of a print job or handing printing errors.

UIKit Printing Error Domain

The error domain for printer errors

UIKit Printing Error Codes

Error codes for UIKit printing errors.

Relationships

Inherits From