-6

ペン先にprintscreenという名前のボタンがあります。.mファイルには、-(IBAction)printscreen{}があります。

ボタンをクリックしたときにスクリーンショットが印刷されるように、{}の間に何を入れる必要がありますか。画像を保存したくないし、ファイルに保存したくないし、ナンセンスなこともしたくない。ボタンをクリックしたいのですが、クリックするとすぐに現在の画面に表示されているものがすべて印刷されます。

私はすべての質問に答えましたが、どれも非常に役に立ちませんでした。ここでコードを探しています。手伝ってください。

4

1 に答える 1

5

You can get an UIImage representation of the screenshot using something like this:

#import <QuartzCore/QuartzCore.h>

UIGraphicsBeginImageContext(view.window.bounds.size);
[view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Then you can do anything with it; maybe you want to write it to the Photo Library:

UIImageWriteToSavedPhotosAlbum(screenshot, nil, NULL, NULL);

As far as I'm concerned, immediate programmatical AirPrint printing is not implemented, you always have to go through the UIPrintInteractionController class.

于 2012-08-12T21:13:26.347 に答える