Class: UIPrintInteractionController

Inherits:
NSObject show all

Overview

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

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Object) delegate

The delegate of the print interaction controller. The delegate must adopt the UIPrintInteractionControllerDelegate protocol and implement one or more of its methods. It is not retained.

Returns:

- (UIPrintFormatter) printFormatter

An object that lays out the content of pages based on the kind of content. Assign to this property an instance of one of the concrete subclasses of UIPrintFormatter: UISimpleTextPrintFormatter, UIMarkupTextPrintFormatter, and UIViewPrintFormatter. This object is released at the end of the print job.If you set this property, UIPrintInteractionController sets the printingItems, printingItem, and printPageRenderer properties to nil. (Only one of these properties can be set for a print job.) If this property is set and the showsPageRange property is set to YES—and if the formatter represents content of more than one page—the printing options include the control for selecting a page range.

Returns:

- (UIPrintInfo) printInfo

An object encapsulating information about the print job. An instance of UIPrintInfo includes properties such as the print-job name, the printer identifier, the orientation of the printed content, the duplex mode, and the kind of content (general, photo, or grayscale). If you do not assign an instance of UIPrintInfo to this property, the UIKit printing system assumes defaults for many of these properties. Users can modify the selected printer and the duplex mode (if available on the printer). Once the printing options are presented, any changes to the UIPrintInfo object referenced by this property are ignored. The object is released when printing completes.

Returns:

- (Object) printingItem

A single ready-to-print object. The object must be an instance of the NSURL, NSData, UIImage, or ALAsset class. An object of the first two types must reference or contain image data or PDF data. NSURL objects must use the file: or assets-library: scheme or any scheme that can return an NSData object with a registered protocol. Image data (including that encapsulated by UIImage an ALAsset objects) must be in a format supported by the Image I/O framework; see “Supported Image Formats” in UIImage Class Reference for more information. An ALAsset object must be of type ALAssetTypePhoto. The object is released at the end of the print job. The default value is nil.If you set this property, UIPrintInteractionController sets the printingItems, printPageRenderer, and printFormatter properties to nil. (Only one of these properties can be set for a print job.) If this property is set and the showsPageRange property is set to YES—and the printing item is a PDF document of more than one page—the printing options include the control for selecting a page range.

Returns:

- (Array) printingItems

An array of ready-to-print objects. The array must contain NSURL, NSData, UIImage, or ALAsset objects in any combination. Objects of the first two types must reference or contain image data or PDF data. NSURL objects must use the file: or assets-library: scheme or any scheme that can return an NSData object with a registered protocol. Image data (including that encapsulated by UIImage and ALAsset objects) must be in a format supported by the Image I/O framework; see “Supported Image Formats” in UIImage Class Reference for more information. An ALAsset object must be of type ALAssetTypePhoto. Items are printed in array-index order. The array is released at the end of the print job. The default value is nil.If you set this property, UIPrintInteractionController sets the printingItem, printPageRenderer, and printFormatter properties to nil. (Only one of these properties can be set for a print job.) If this property is set, the printing options do not include the control for selecting a page range, even if the showsPageRange property is set to YES. If you want page-range selection, you should use the printingItem property instead.

Returns:

- (UIPrintPageRenderer) printPageRenderer

An object that draws pages of printable content when requested by UIKit. The object assigned to this property must be an instance of a custom subclass of UIPrintPageRenderer. The UIPrintInteractionController class retains the page-renderer object and releases it at the end of the print job. The default value is nil. If you set this property, UIPrintInteractionController sets the printingItems, printingItem, printFormatter properties to nil. (Only one of these properties can be set for a print job.) If this property is set and the showsPageRange property is set to YES—and the rendered content is greater than one page—the printing options include the control for selecting a page range.

Returns:

  • (UIPrintPageRenderer)

- (UIPrintPaper) printPaper (readonly)

An object representing the paper size and printing area for the print job. (read-only) UIPrintInteractionController sets this property immediately after the user selects a printer and before it calls the delegate’s printInteractionControllerWillStartJob: method. If its delegate implements the printInteractionController:choosePaper: method of the UIPrintInteractionControllerDelegate protocol, it can return the UIPrintPaper object to assign to this property. Otherwise, UIKit assigns an object with a default paper size and printing rectangle that is based on the output type and the capabilities of the destination printer. This object is released when the print job finishes.

Returns:

- (Boolean) showsPageRange

A Boolean value that determines whether the printing options include a page-range control. The default value is NO. If you assign printable content to the printingItems property, the page-range control is not shown, even if showPageRange is YES. In other cases, the number of pages to print must be greater than 1 form the page-range control to appear.

Returns:

  • (Boolean)

Class Method Details

+ (Boolean) canPrintData(data)

Returns whether UIKit can print the contents of a data object. You should call this method to test a data object prior to assigning it to printingItem or printingItems.

Parameters:

  • data (NSData)

    An instance of the NSData class that contains PDF data or an image in a format supported by the Image I/O framework. See “Supported Image Formats” in View Programming Guide for iOS for a list of the supported image formats.

Returns:

  • (Boolean)

    YES if UIKit can print the contents of the data object, otherwise NO. The method returns NO if data is PDF data that specifies that printing is not allowed.

+ (Boolean) canPrintURL(url)

Returns whether UIKit can print the file referenced by a URL. You should call this method to test the data referenced by a URL prior to assigning that URL to printingItem or printingItems.

Parameters:

  • url (NSURL)

    An object representing a URL. Valid NSURL objects must use the file: or assets-library: scheme or any scheme that can return an NSData object with a registered protocol. The file referenced by the URL must contain PDF data or an image in a format supported by the Image I/O framework. See “Supported Image Formats” in View Programming Guide for iOS for a list of the supported image formats.

Returns:

  • (Boolean)

    YES if UIKit can print the contents of the referenced file, otherwise NO. The method returns NO if url references PDF data that specifies that printing is not allowed.

+ (Boolean) isPrintingAvailable

Returns a Boolean indicating whether the device supports printing.

Returns:

  • (Boolean)

    YES if the device supports printing, otherwise NO. An application can show or hide any print buttons based on this value.

+ (NSSet) printableUTIs

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

Returns:

  • (NSSet)

    A set object that contains, as strings, the UTIs identifying data types that UIKit knows how to print natively.

+ (UIPrintInteractionController) sharedPrintController

Returns the shared print-interaction controller object.

Returns:

Instance Method Details

- (Object) dismissAnimated(animated)

Dismisses the printing-options sheet or popover. You should dismiss the printing options when they are presented in a sheet or animated from a rectangle and the user changes the orientation of the device. (This, of course, assumes your application responds to orientation changes.) You should then present the printing options again once the new orientation takes effect. You can observe the UIApplicationWillChangeStatusBarOrientationNotification notification to find out when the device orientation is about to change.

Parameters:

  • animated (Boolean)

    YES to animate the dismissal, otherwise NO.

Returns:

- (Object) presentAnimated(animated, completionHandler:completion)

Presents the iPhone printing user interface in a sheet that can be animated to slide up from the bottom of the screen. It is valid to call this method for applications on iPhone and iPod touch devices. Calling this method on an iPad with animated set to YES causes the printing options view to animate from the window frame.If you call this method when the printing options are already displayed, UIPrintInteractionController hides the printing-options sheet. You must call the method again to display the options.

Parameters:

  • animated (Boolean)

    YES to animate the display of the sheet, NO to display the sheet immediately.

  • completion (UIPrintInteractionCompletionHandler)

    A block of type UIPrintInteractionCompletionHandler that you implement to handle the conclusion of the print job (for instance, to reset state) and to handle any errors encountered in printing.

Returns:

- (Object) presentFromBarButtonItem(item, animated:animated, completionHandler:completion)

Presents the iPad printing user interface in a popover view that can be animated from a bar-button item. It is valid to call this method for applications on iPad devices. Calling this method on an iPhone or iPod touch with animated set to YES causes the printing options view to animate upward from the bottom of the screen.If you call this method when the printing options are already displayed, UIPrintInteractionController hides the printing-options popover view. You must call the method again to display the options.

Parameters:

  • item (UIBarButtonItem)

    The UIBarButtonItem object that the user tapped for printing. You are encouraged to use the constant UIBarButtonSystemItemAction when creating a bar-button item for this purpose.

  • animated (Boolean)

    YES to animate the printing popover view from item, NO to display it immediately.

  • completion (UIPrintInteractionCompletionHandler)

    A block of type UIPrintInteractionCompletionHandler that you implement to handle the conclusion of the print job (for instance, to reset state) and to handle any errors encountered in printing.

Returns:

- (Object) presentFromRect(rect, inView:view, animated:animated, completionHandler:completion)

Presents the iPad printing user interface in a popover view that can be animated from any area in a view. It is valid to call this method for applications on iPad devices. Calling this method on an iPhone or iPod touch with animated set to YES causes the printing options view to animate upward from the bottom of the screen.If you call this method when the printing options are already displayed, UIPrintInteractionController hides the printing-options popover view. You must call the method again to display the options.

Parameters:

  • rect (CGRect)

    A rectangle that defines the area from which the printing popover view is animated.

  • view (UIView)

    The view providing the coordinate system for rect.

  • animated (Boolean)

    YES to animate the printing popover view from item, NO to display it immediately.

  • completion (UIPrintInteractionCompletionHandler)

    A block of type UIPrintInteractionCompletionHandler that you implement to handle the conclusion of the print job (for instance, to reset state) and to handle any errors encountered in printing.

Returns: