質問編集履歴
1
コードを伝わりやすく書き直し
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
導入ガイドなどで調べながら試しているのですが、
|
9
9
|
ダイアログ正解後に広告、そして画面遷移というところがうまくできません。
|
10
10
|
|
11
|
-
広告
|
11
|
+
ダイアログの質問回答後、広告も表示されず画面遷移もしません。
|
12
12
|
|
13
13
|
|
14
14
|
```swift
|
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
@IBAction func test(_ sender: Any) {
|
40
40
|
|
41
|
-
|
41
|
+
|
42
42
|
if interstitial.isReady {
|
43
43
|
interstitial.present(fromRootViewController: self)
|
44
44
|
|
@@ -54,6 +54,17 @@
|
|
54
54
|
alert.addAction(UIAlertAction(title: "解答する", style: .default) { _ in
|
55
55
|
if let answer = alert.textFields?.first?.text {
|
56
56
|
if answer == "(self.a + self.b)" {
|
57
|
+
|
58
|
+
//広告
|
59
|
+
self.interstitial = createAndLoadInterstitial()
|
60
|
+
}
|
61
|
+
func createAndLoadInterstitial() -> GADInterstitial {
|
62
|
+
let interstitial = GADInterstitial(adUnitID: "ca-app-pub-2929539065928288/6968941950")
|
63
|
+
interstitial.delegate = self
|
64
|
+
interstitial.load(GADRequest())
|
65
|
+
return interstitial
|
66
|
+
}
|
67
|
+
}
|
57
68
|
let nextViewController = self.storyboard?.instantiateViewController(withIdentifier: "second") as! nextViewController
|
58
69
|
self.present(nextViewController, animated: true, completion: nil)
|
59
70
|
}
|