質問編集履歴

1

コードの変更

2019/01/28 07:39

投稿

DrqYuto
DrqYuto

スコア432

test CHANGED
File without changes
test CHANGED
@@ -75,3 +75,91 @@
75
75
  参考
76
76
 
77
77
  http://blue-bear.jp/kb/swift-label%E3%82%84view%E3%82%92%E8%A1%A8%E7%A4%BA%E3%83%BB%E9%9D%9E%E8%A1%A8%E7%A4%BA%E3%82%92%E5%88%87%E3%82%8A%E6%9B%BF%E3%81%88%E3%82%8B/
78
+
79
+
80
+
81
+ ```
82
+
83
+ import UIKit
84
+
85
+ import AVFoundation
86
+
87
+
88
+
89
+ class ViewController: UIViewController {
90
+
91
+
92
+
93
+ @IBOutlet weak var image1: UIImageView!
94
+
95
+
96
+
97
+ @IBAction func button3(_ sender: UIButton) {
98
+
99
+ image1.image = UIImage(named: "kaka")!
100
+
101
+
102
+
103
+ let talker = AVSpeechSynthesizer()
104
+
105
+ // 話す内容をセット
106
+
107
+ let utterance = AVSpeechUtterance(string: "kaka")
108
+
109
+ // 言語を日本に設定
110
+
111
+ utterance.voice = AVSpeechSynthesisVoice(language: "ja-JP")
112
+
113
+ // 実行
114
+
115
+ talker.speak(utterance)
116
+
117
+
118
+
119
+ func changeVisible(visible: Bool) {
120
+
121
+ if visible == true {
122
+
123
+ image1.isHidden = false
124
+
125
+ } else {
126
+
127
+ image1.isHidden = true
128
+
129
+ }
130
+
131
+ }
132
+
133
+ }
134
+
135
+
136
+
137
+ override func viewDidLoad() {
138
+
139
+ super.viewDidLoad()
140
+
141
+ // Do any additional setup after loading the view, typically from a nib.
142
+
143
+ }
144
+
145
+ // 表示/非表示を切り替え
146
+
147
+ // func changeVisible(visible: Bool) {
148
+
149
+ // if visible == true {
150
+
151
+ // image1.isHidden = false
152
+
153
+ // } else {
154
+
155
+ // image1.isHidden = true
156
+
157
+ // }
158
+
159
+ // }
160
+
161
+ }
162
+
163
+ ```
164
+
165
+ 接続されてないのが原因かと思い@IBActionの中に入れてみましたがビルドは通りましたがだめでした。非表示になりませんでした。