質問編集履歴
2
プログラムの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,24 +1,27 @@
|
|
1
1
|
保存ボタンを押すとそのViewに表示されてる状態をPDFに保存したいです
|
2
2
|
色々なサイトを見たのですがどうしても分からない状態です
|
3
3
|
```
|
4
|
-
@IBAction func CreatePDF(
|
4
|
+
@IBAction func CreatePDF(vi: UIView) {
|
5
|
-
|
5
|
+
print("pdfを作ります!")
|
6
|
+
|
6
7
|
let pdfData = NSMutableData()
|
8
|
+
let documentsPath = NSHomeDirectory() + "/Documents" + "/test.pdf"
|
9
|
+
let vi = UIView(frame: vi.bounds)
|
7
|
-
|
10
|
+
UIGraphicsBeginPDFContextToData(pdfData, vi.bounds, nil)
|
8
|
-
|
9
|
-
UIGraphicsBeginPDFPage()
|
10
11
|
|
12
|
+
UIGraphicsGetCurrentContext()
|
13
|
+
UIGraphicsBeginPDFPageWithInfo(vi.bounds, nil);
|
14
|
+
UIGraphicsEndPDFContext()
|
11
15
|
|
12
|
-
|
16
|
+
pdfData.write(toFile: documentsPath, atomically: true)
|
13
17
|
|
14
|
-
aView.layer.render(in: pdfContext!)
|
15
|
-
UIGraphicsEndPDFContext()
|
16
|
-
|
17
|
-
let documentDirectories = NSHomeDirectory() + "/Documents"
|
18
|
-
let documentsFileName = documentDirectories + "/test.pdf"
|
19
|
-
|
18
|
+
print(documentsPath)
|
20
19
|
}
|
20
|
+
|
21
21
|
```
|
22
|
-
|
22
|
+
test.pdfファイルは作成されますが、真っ白なPDFが出来るだけです。
|
23
|
+
|
24
|
+
Viewの表示内容がpdfDataに代入されてないからだと思うのですが・・・・
|
25
|
+
|
23
26
|
アプリを初めて作り出しました。サイトを色々見たりしてるのですが難しくて先に進めません。
|
24
27
|
宜しくお願い致します
|
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
保存ボタンを押すとそのViewに表示されてる状態をPDFに保存したいです
|
2
2
|
色々なサイトを見たのですがどうしても分からない状態です
|
3
|
-
|
3
|
+
```
|
4
4
|
@IBAction func CreatePDF(aView: UIView) {
|
5
5
|
|
6
6
|
let pdfData = NSMutableData()
|
@@ -18,7 +18,7 @@
|
|
18
18
|
let documentsFileName = documentDirectories + "/test.pdf"
|
19
19
|
debugPrint(documentsFileName)
|
20
20
|
}
|
21
|
-
|
21
|
+
```
|
22
22
|
このままではエラーが出てしまいます
|
23
23
|
アプリを初めて作り出しました。サイトを色々見たりしてるのですが難しくて先に進めません。
|
24
24
|
宜しくお願い致します
|