2011年2月13日日曜日

UIPrintInteractionController Class Reference


Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 4.2 and later.
Companion guide
Declared in
UIPrintError.h
UIPrintInteractionController.h

Overview

UIPrintInteractionController クラスの共有インスタンスは、プリントするユーザインタフェースを表示し、ドキュメントやイメージやその他の印刷可能なiOSオブジェクトの印刷を管理する。
UIPrintInteractionController は、iOSの印刷のための中心となるクラスとなる。この共有インスタンスは、プリントジョブを代表する。プリントジョブは、プリントすべき内容と情報とプリントに関係するオプション(アウトプットタイプ、ジョブ名、ペーパサイズ、方向)を包含する。
UIPrintInteractionController は、プリントすべき内容に応じて与えられた4つの相互に排他的なプロパティを持つ。
  • printingItem は、単一のプリント可能なオブジェクトを取得する。
  • printingItems プリント可能な配列オブジェクトを取得する。
  • printFormatter ある種の内容をどのようにレイアウトするかを知るオブジェクトであるプリントフォーマッタを取得する。
  • printPageRenderer プリントする内容を描画するためのカスタムオブジェクトであるページレンダラを取得する。
もし showsPageRange プロパティがYESにセットされていれば, ページ数が1以上で,  printingItems プロパティ(ユーザにページ範囲を指定することを許す制御を含むプリンタオプション)の場合をのぞいて、これらの任意のオブジェクトを割り当てる。 
ユーザがアプリケーションのユーザインタフェース上にあるプリントボタンをタップしたとき、アプリケーションのコントローラオブジェクトは、UIPrintInteractionController の共有インスタンスとプリントジョブのために準備を含むアクションメッセージを返すべきである。
present... メソッド (例えば、presentAnimated:completionHandler:)のうちの一つをアプリケーションが呼ぶとき、 UIPrintInteractionController は、プリントオプションを含むビューを表示する。このインタフェースは、簡単に、コピー数とページ範囲を指定し、片面印刷か両面印刷かの選択(もし、プリンタが両面印刷をサポートしていたら)のユーザによるプリンタの選択を許す。ユーザがそれらの選択をし、プリントをタップするとプインとは開始する。
Tasks

共有コントローラインスタンスを取得する

プリント可否を決定する

プリント可能なコンテンツのソースを提供する

プリントのユーザインタフェースを表示する

プリントジョブの情報にアクセスする

デリゲートを割りあてる

Properties

For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.

delegate

The delegate of the print interaction controller.
@property(nonatomic, assign) id<UIPrintInteractionControllerDelegate> delegate
Discussion
The delegate must adopt the UIPrintInteractionControllerDelegate protocol and implement one or more of its methods. It is not retained.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printFormatter

An object that lays out the content of pages based on the kind of content.
@property(nonatomic, retain) UIPrintFormatter *printFormatter
Discussion
Assign to this property an instance of one of the concrete subclasses of UIPrintFormatter:UISimpleTextPrintFormatterUIMarkupTextPrintFormatter, and UIViewPrintFormatter. This object is released at the end of the print job.
If you set this property, UIPrintInteractionController sets the printingItemsprintingItem, andprintPageRenderer 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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printInfo

An object encapsulating information about the print job.
@property(nonatomic, retain) UIPrintInfo *printInfo
Discussion
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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printingItem

A single ready-to-print object.
@property(nonatomic, copy) id printingItem
Discussion
The object must be an instance of the NSURLNSDataUIImage, 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 byUIImage 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 printingItemsprintPageRenderer, andprintFormatter 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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printingItems

An array of ready-to-print objects.
@property(nonatomic, copy) NSArray *printingItems
Discussion
The array must contain NSURLNSDataUIImage, 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 typeALAssetTypePhoto. 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 printingItemprintPageRenderer, andprintFormatter 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 theshowsPageRange property is set to YES. If you want page-range selection, you should use the printingItem property instead.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printPageRenderer

An object that draws pages of printable content when requested by UIKit.
@property(nonatomic, retain) UIPrintPageRenderer printPageRenderer
Discussion
The object assigned to this property must be an instance of a custom subclass of UIPrintPageRenderer. TheUIPrintInteractionController 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 printingItemsprintingItem,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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printPaper

An object representing the paper size and printing area for the print job. (read-only)
@property(nonatomic, readonly) UIPrintPaper *printPaper
Discussion
UIPrintInteractionController sets this property immediately after the user selects a printer and before it calls the delegate’s printInteractionControllerWillStartJob: method. If its delegate implements theprintInteractionController: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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

showsPageRange

A Boolean value that determines whether the printing options include a page-range control.
@property(nonatomic) BOOL showsPageRange
Discussion
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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

Class Methods

canPrintData:

Returns whether UIKit can print the contents of a data object.
+ (BOOL)canPrintData:(NSData *)data
Parameters
data
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.
Return Value
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.
Discussion
You should call this method to test a data object prior to assigning it to printingItem or printingItems.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

canPrintURL:

Returns whether UIKit can print the file referenced by a URL.
+ (BOOL)canPrintURL:(NSURL *)url
Parameters
url
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.
Return Value
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.
Discussion
You should call this method to test the data referenced by a URL prior to assigning that URL to printingItem orprintingItems.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

isPrintingAvailable

Returns a Boolean indicating whether the device supports printing.
+ (BOOL)isPrintingAvailable
Return Value
YES if the device supports printing, otherwise NO. An application can show or hide any print buttons based on this value.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printableUTIs

Returns a set of the Uniform Type Identifiers for the types of data that UIKit can print.
+ (NSSet *)printableUTIs
Return Value
A set object that contains, as strings, the UTIs identifying data types that UIKit knows how to print natively.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

sharedPrintController

Returns the shared print-interaction controller object.
+ (UIPrintInteractionController *)sharedPrintController
Return Value
The singleton instance of the UIPrintInteractionController class or nil if the object could not be created.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

Instance Methods

dismissAnimated:

Dismisses the printing-options sheet or popover.
- (void)dismissAnimated:(BOOL)animated
Parameters
animated
YES to animate the dismissal, otherwise NO.
Discussion
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 theUIApplicationWillChangeStatusBarOrientationNotification notification to find out when the device orientation is about to change.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

presentAnimated:completionHandler:

Presents the iPhone printing user interface in a sheet that can be animated to slide up from the bottom of the screen.
- (void)presentAnimated:(BOOL)animatedcompletionHandler:(UIPrintInteractionCompletionHandler)completion
Parameters
animated
YES to animate the display of the sheet, NO to display the sheet immediately.
completion
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.
Discussion
It is valid to call this method for applications on iPhone and iPod touch devices. Calling this method on an iPad withanimated 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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

presentFromBarButtonItem:animated:completionHandler:

Presents the iPad printing user interface in a popover view that can be animated from a bar-button item.
- (void)presentFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animatedcompletionHandler:(UIPrintInteractionCompletionHandler)completion
Parameters
item
The UIBarButtonItem object that the user tapped for printing. You are encouraged to use the constantUIBarButtonSystemItemAction when creating a bar-button item for this purpose.
animated
YES to animate the printing popover view from itemNO to display it immediately.
completion
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.
Discussion
It is valid to call this method for applications on iPad devices. Calling this method on an iPhone or iPod touch withanimated 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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

presentFromRect:inView:animated:completionHandler:

Presents the iPad printing user interface in a popover view that can be animated from any area in a view.
- (void)presentFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animatedcompletionHandler:(UIPrintInteractionCompletionHandler)completion
Parameters
rect
A rectangle that defines the area from which the printing popover view is animated.
view
The view providing the coordinate system for rect.
animated
YES to animate the printing popover view from itemNO to display it immediately.
completion
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.
Discussion
It is valid to call this method for applications on iPad devices. Calling this method on an iPhone or iPod touch withanimated 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.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

Constants

UIPrintInteractionCompletionHandler

The type of block callback for responding to the completion of a print job or handing printing errors.
typedef void (^UIPrintInteractionCompletionHandler)
   (UIPrintInteractionController *printInteractionController,BOOL completed, NSError *error);
Discussion
You implement this block as the final argument of presentAnimated:completionHandler:,presentFromBarButtonItem:animated:completionHandler:, orpresentFromRect:inView:animated:completionHandler:. When a print job concludes, you can reset any state set up for printing and do related housekeeping tasks. If the print job encountered an error, it is likely to be a programming error, so you might want to log the error for debugging purposes.
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
completed
A Boolean value that indicates whether the print job completed successfully.
error
An instance of the NSError that contains information about the printing error. The printing domain isUIPrintErrorDomain. The printing error codes are described in “UIKit Printing Error Codes.” If the print job completes successfully, this parameter is nil.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

UIKit Printing Error Domain

The error domain for printer errors
UIKIT_EXTERN NSString *const UIPrintErrorDomain;
Constants
UIPrintErrorDomain
The string constant defining the UIKit printing error domain.
Available in iOS 4.2 and later.
Declared in UIPrintError.h.
Declared In
UIPrintError.h

UIKit Printing Error Codes

Error codes for UIKit printing errors.
enum {
   UIPrintingNotAvailableError = 1,
   UIPrintNoContentError,
   UIPrintUnknownImageFormatError,
   UIPrintJobFailedError,
};
Constants
UIPrintingNotAvailableError
The device does not support printing.
Available in iOS 4.2 and later.
Declared in UIPrintError.h.
UIPrintNoContentError
No print formatter, page renderer, printing item or printing items was assigned for printing.
Available in iOS 4.2 and later.
Declared in UIPrintError.h.
UIPrintUnknownImageFormatError
An image is in a format not recognized by UIKit for printing.
Available in iOS 4.2 and later.
Declared in UIPrintError.h.
UIPrintJobFailedError
An internal error occurred with the print job.
Available in iOS 4.2 and later.
Declared in UIPrintError.h.
Declared In
UIPrintError.h

UIPrintInteractionControllerDelegate Protocol Reference


Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 4.2 and later.
Companion guide
Declared in
UIPrintInteractionController.h

Overview

UIPrintInteractionControllerDelegate プロトコルは UIPrintInteractionController のデリゲートにより実装されている。
UIPrintInteractionController は多くのオプションタスクを実行するためのインスタンスを共有する。
もしアプリケーションがコンテンツのサイズのための特別な要件があるならば、printInteractionController:choosePaper: で実装できる。
printInteractionController:choosePaper:は、UIPrintPaper オブジェクトを返すため、 プリントジョブのために使うページサイズとプリントエリアを包含する。
もし、もっと多くのプリントオブションの表現の制御を必要とするならば、デリゲートはprintInteractionControllerParentViewController:.の実装においてプリントオプションのビューを持つビューコントローラを返す。
デリゲートは、プリントのユーザインタフェースが表示されたときと終了したとき、またプリントジョブが始まったときと終ったときに動作するメソッドを実装できる。

Instance Methods


printInteractionController:choosePaper:

Asks the delegate for an object encapsulating the paper size and printing area to use for the print job.
- (UIPrintPaper *)printInteractionController:(UIPrintInteractionController*)printInteractionController choosePaper:(NSArray *)paperList
Parameters
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
paperList
An array of UIPrintPaper objects that represent combinations of paper sizes and imageable areas supported by the selected printer.
Return Value
UIPrintPaper object representing both the paper size and imageable area (or printable rectangle) to use for the print job. If you return nil, a UIPrintPaper encapsulating the default paper size and printable rectangle is used.
Discussion
This method is intended for applications (typically document-based) that have a notion of distinct paper sizes. The delegate can examine the objects in paperList to locate the paper size and printable rectangle combination that is best suited for its needs and return the encapsulating UIPrintPaper object. Or it can call thebestPaperForPageSize:withPapersFromArray: class method of the UIPrintPaper class, passing in a specific page size (typically the document size), and return the object returned by that method.
Availability
  • Available in iOS 4.2 and later.
See Also
Declared In
UIPrintInteractionController.h

printInteractionControllerDidDismissPrinterOptions:

Tells the delegate that the printer user interface is being dismissed.
- (void)printInteractionControllerDidDismissPrinterOptions:(UIPrintInteractionController*)printInteractionController
Parameters
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
Discussion
This message is sent both when the user taps Print on the printing-options view and when the user dismisses the view by tapping outside it.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printInteractionControllerDidFinishJob:

Tells the delegate that the print job has ended.
- (void)printInteractionControllerDidFinishJob:(UIPrintInteractionController*)printInteractionController
Parameters
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
Discussion
You can implement this method to do clean-up tasks related to the print job. This method is called after the last page of the print job is generated but before the completion handler (a block handler of typeUIPrintInteractionCompletionHandler) is called.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printInteractionControllerDidPresentPrinterOptions:

Tells the delegate that the printing-options user interface has just been presented.
- (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController*)printInteractionController
Parameters
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printInteractionControllerParentViewController:

Returns a parent view controller for managing the printing-options view.
- (UIViewController*)printInteractionControllerParentViewController:(UIPrintInteractionController*)printInteractionController
Parameters
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
Return Value
The view controller that is to be the parent of the print-interaction controller managing the printing-options view. Return nil for the standard presentation behavior.
Discussion
This method allows an application to present the print-options view from a view controller of their own choosing. The parent view controller returned must be a UIViewController object, such as a UINavigationController object or a generic view controller. A common strategy for embedding is to create a UINavigationController object as the content view controller (contentViewController property) of a UIPopoverController object and return that. UIKit can push the returned view controller onto the stack if its parent is a navigation controller or present it modally if it isn’t.
This method is invoked in any of the present... methods of the UIPrintInteractionController class (for example, presentAnimated:completionHandler:).
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printInteractionControllerWillDismissPrinterOptions:

Tells the delegate that the printing-options user interface will be dismissed.
- (void)printInteractionControllerWillDismissPrinterOptions:(UIPrintInteractionController*)printInteractionController
Parameters
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printInteractionControllerWillPresentPrinterOptions:

Tells the delegate that the printing-options user interface is about to be displayed.
- (void)printInteractionControllerWillPresentPrinterOptions:(UIPrintInteractionController*)printInteractionController
Parameters
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

printInteractionControllerWillStartJob:

Tells the delegate that the print job is about to start.
- (void)printInteractionControllerWillStartJob:(UIPrintInteractionController*)printInteractionController
Parameters
printInteractionController
The shared instance of UIPrintInteractionController that is managing the print job.
Discussion
You can implement this method to do set-up tasks related to the print job. For example, an application that needs to do intensive rendering could implement this method to pause animations. This method is called before drawing begins but after the printing user interface is dismissed.
Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintInteractionController.h

2011年2月11日金曜日

巻き紙電卓の売り上げが日米逆転しました。

本日は米国からのダウンロードが日本を上回り、はじめて日本の売り上げが1位ではなくなりました。

このままあがってくれるといいけどなぁ。

2011年2月6日日曜日

六次の隔たり

六字の隔たりとは、ソーシャルネットワークを通じた宣伝/社会現象発生の基礎理論となるもので、世界中の人々と6人を介せば間接的な知り合いになれるというものです。もっとも44人の友人がいるという前提だそうで、そんなにはいないかなー、という感じです(フォロワーと友人は違うしねー)。

六次の隔たり(ろくじのへだたり、Six Degrees of Separation)とは、人は自分の知り合いを6人以上介すと世界中の人々と間接的な知り合いになれる、という仮説で、多くの人数からなる世界が比較的少ない人数を介して繋がるスモール・ワールド現象の一例とされる。SNSに代表されるいくつかのネットワークサービスはこの仮説が下地になっている。
この仮説は後述のスタンレー・ミルグラムの実験を裏づけとして大きく広まったが、それ以前から文学作品などを通じて古くから知られていた。この仮説を描いた最古の作品はハンガリーの文学者フリジェシュ・カリンティによる1929年の小説『鎖』とされているが[1]、「六次の隔たり」という名称は、劇作家ジョン・グエアの戯曲に由来する。この戯曲は後に『私に近い6人の他人』(原題:Six Degrees of Separation)として映画化された。

Wikiサイト