質問編集履歴
5
コードを現状のものに修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,13 +38,11 @@
|
|
38
38
|
|
39
39
|
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
-
let imageNames = ["futako.jpg", "
|
45
|
+
let imageNames = ["futako.jpg", "fran.jpg","yokado.jpg", "zikken.jpg"]
|
46
|
-
|
47
|
-
|
48
46
|
|
49
47
|
|
50
48
|
|
@@ -52,9 +50,7 @@
|
|
52
50
|
|
53
51
|
|
54
52
|
|
55
|
-
|
56
|
-
|
57
|
-
let imageTitles = ["イヌ
|
53
|
+
let imageTitles = ["イヌ", "イヌ", "ネコ", "ネコ"]
|
58
54
|
|
59
55
|
var audioPlayer = AVAudioPlayer()
|
60
56
|
|
@@ -62,17 +58,17 @@
|
|
62
58
|
|
63
59
|
let imageDescriptions = [
|
64
60
|
|
65
|
-
"
|
61
|
+
"2018/10/30",
|
66
|
-
|
62
|
+
|
67
|
-
"
|
63
|
+
"2018/10/30",
|
68
|
-
|
64
|
+
|
69
|
-
"
|
65
|
+
"2018/10/30",
|
70
|
-
|
66
|
+
|
71
|
-
"
|
67
|
+
"2018/10/30"
|
72
68
|
|
73
69
|
]
|
74
70
|
|
75
|
-
|
71
|
+
|
76
72
|
|
77
73
|
override func viewDidLoad() {
|
78
74
|
|
@@ -82,7 +78,7 @@
|
|
82
78
|
|
83
79
|
}
|
84
80
|
|
85
|
-
|
81
|
+
|
86
82
|
|
87
83
|
override func didReceiveMemoryWarning() {
|
88
84
|
|
@@ -126,7 +122,7 @@
|
|
126
122
|
|
127
123
|
func selectCellButton(_ index: IndexPath) {
|
128
124
|
|
129
|
-
let fileName = "sound
|
125
|
+
let fileName = String(format: "sound%02d", index.row+1)
|
130
126
|
|
131
127
|
|
132
128
|
|
@@ -154,126 +150,124 @@
|
|
154
150
|
|
155
151
|
}
|
156
152
|
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
@IBAction func tapButton(_ sender: UIButton) {
|
160
|
+
|
161
|
+
var hoge = sender.superview
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
while(hoge!.isKind(of: UITableViewCell.self) == false) {
|
166
|
+
|
167
|
+
hoge = hoge!.superview
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
let cell = hoge as! UITableViewCell
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
let indexPath = self.tableView.indexPath(for: cell)
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
print(indexPath)
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
self.selectCellButton(index)
|
186
|
+
|
187
|
+
}
|
188
|
+
|
157
189
|
}
|
158
190
|
|
159
191
|
|
160
192
|
|
193
|
+
```
|
194
|
+
|
195
|
+
```
|
196
|
+
|
197
|
+
<ここからはCustomTableViewCellのコードです>
|
198
|
+
|
199
|
+
// CustomTableViewCell.swift
|
200
|
+
|
201
|
+
import UIKit
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
class CustomTableViewCell: UITableViewCell {
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
@IBOutlet weak var myImageView: UIImageView!
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
@IBOutlet weak var myTitleLabel: UILabel!
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
@IBOutlet weak var myDescriptionLabel: UILabel!
|
220
|
+
|
221
|
+
|
222
|
+
|
161
|
-
@IB
|
223
|
+
@IBOutlet weak var tapButton: UIButton!
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
162
|
-
|
229
|
+
// weak var delegate: CustomTableViewCellDelegate!
|
230
|
+
|
163
|
-
|
231
|
+
var index: IndexPath!
|
164
|
-
|
165
|
-
|
166
|
-
|
232
|
+
|
233
|
+
|
234
|
+
|
167
|
-
|
235
|
+
override func awakeFromNib() {
|
168
|
-
|
236
|
+
|
169
|
-
|
237
|
+
super.awakeFromNib()
|
238
|
+
|
170
|
-
|
239
|
+
// Initialization code
|
240
|
+
|
171
|
-
|
241
|
+
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
242
|
+
|
176
|
-
|
177
|
-
|
178
|
-
|
243
|
+
|
244
|
+
|
179
|
-
|
245
|
+
override func setSelected(_ selected: Bool, animated: Bool) {
|
180
|
-
|
181
|
-
|
182
|
-
|
246
|
+
|
183
|
-
pr
|
247
|
+
super.setSelected(selected, animated: animated)
|
184
|
-
|
185
|
-
|
186
|
-
|
248
|
+
|
249
|
+
|
250
|
+
|
187
|
-
//
|
251
|
+
// Configure the view for the selected state
|
188
|
-
|
252
|
+
|
189
|
-
}
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
func setCell(_ imageName: String, titleText: String, descriptionText: String) {
|
258
|
+
|
259
|
+
myImageView.image = UIImage(named: imageName)
|
260
|
+
|
261
|
+
myTitleLabel.text = titleText
|
262
|
+
|
263
|
+
myDescriptionLabel.text = descriptionText
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
|
190
268
|
|
191
269
|
}
|
192
270
|
|
271
|
+
|
272
|
+
|
193
|
-
```
|
273
|
+
```
|
194
|
-
|
195
|
-
```
|
196
|
-
|
197
|
-
<ここからはCustomTableViewCellのコードです>
|
198
|
-
|
199
|
-
// CustomTableViewCell.swift
|
200
|
-
|
201
|
-
import UIKit
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
class CustomTableViewCell: UITableViewCell {
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
@IBOutlet weak var myImageView: UIImageView!
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
@IBOutlet weak var myTitleLabel: UILabel!
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
@IBOutlet weak var myDescriptionLabel: UILabel!
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
@IBOutlet weak var tapButton: UIButton!
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
// weak var delegate: CustomTableViewCellDelegate!
|
238
|
-
|
239
|
-
var index: IndexPath!
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
override func awakeFromNib() {
|
244
|
-
|
245
|
-
super.awakeFromNib()
|
246
|
-
|
247
|
-
// Initialization code
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
override func setSelected(_ selected: Bool, animated: Bool) {
|
254
|
-
|
255
|
-
super.setSelected(selected, animated: animated)
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
// Configure the view for the selected state
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
func setCell(_ imageName: String, titleText: String, descriptionText: String) {
|
266
|
-
|
267
|
-
myImageView.image = UIImage(named: imageName)
|
268
|
-
|
269
|
-
myTitleLabel.text = titleText
|
270
|
-
|
271
|
-
myDescriptionLabel.text = descriptionText
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
}
|
278
|
-
|
279
|
-
```
|
4
追記しました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Breakpointは削除していいものなのか?
|
1
|
+
Breakpointsは削除していいものなのか?
|
test
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
『0x109ec616b <+43>: movq %rdi, -0x68(%rbp)』という表示の横にThread1:breakpoint1.1というものが表示され、実行ができなかったので、ネットで対処法を調べたらBreakPointを削除したらいいと書かれていたので、削除しました。
|
1
|
+
『0x109ec616b <+43>: movq %rdi, -0x68(%rbp)』という表示の横にThread1:breakpoint1.1というものが表示され、実行ができなかったので、ネットで対処法を調べたらBreakPointsを削除したらいいと書かれていたので、削除しました。
|
2
2
|
|
3
3
|
すると実行でできたのですが、今度は、Buttonを押すと、『Thread 1: signal SIGABRT』というものが出るようになりました。そして、その対処法を調べるとBreakPointを追加しろと書かれているサイトを見つけました。
|
4
4
|
|
5
|
-
|
5
|
+
しかし、BreakPointsを追記せず、Buttonを右クリックして、出てきたメニューの注意マーク(!?)のようなものがついているところの左にある❌を押し、再度実行すると、Buttonを押すたびにOptional([0, 0])やOptional([0, 1])といったものがデバッグエリアに追加され続け、音が鳴りません。
|
6
|
-
|
6
|
+
|
7
|
+
|
8
|
+
|
7
|
-
BreakPointは削除していいものなのでしょうか。
|
9
|
+
BreakPointsは削除していいものなのでしょうか。
|
8
10
|
|
9
11
|
|
10
12
|
|
3
追記しました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Breakpointは削除していいものなのか?
|
test
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
delegateとdetaSourceをViewControllerに設定してない場合、エラーも出ないのですが、実行すると何も表示されない。delegateとdetaSourceをViewControllerに設定すると、
|
2
|
-
|
3
|
-
『0x109ec616b <+43>: movq %rdi, -0x68(%rbp)』という表示の横にThread1:breakpoint1.1というものが表示され、実行ができな
|
1
|
+
『0x109ec616b <+43>: movq %rdi, -0x68(%rbp)』という表示の横にThread1:breakpoint1.1というものが表示され、実行ができなかったので、ネットで対処法を調べたらBreakPointを削除したらいいと書かれていたので、削除しました。
|
2
|
+
|
4
|
-
|
3
|
+
すると実行でできたのですが、今度は、Buttonを押すと、『Thread 1: signal SIGABRT』というものが出るようになりました。そして、その対処法を調べるとBreakPointを追加しろと書かれているサイトを見つけました。
|
4
|
+
|
5
|
+
|
6
|
+
|
5
|
-
|
7
|
+
BreakPointは削除していいものなのでしょうか。
|
6
8
|
|
7
9
|
|
8
10
|
|
@@ -273,13 +275,3 @@
|
|
273
275
|
}
|
274
276
|
|
275
277
|
```
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
|
282
|
-
|
283
|
-
上記のコードを実行すると、Cellのラインは表示されるのですが、
|
284
|
-
|
285
|
-
イメージ、ラベルは表示されず、音を鳴らすこともできません。
|
2
質問内容を少し変えてみました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
|
1
|
+
delegateとdetaSourceをViewControllerに設定してない場合、エラーも出ないのですが、実行すると何も表示されない。delegateとdetaSourceをViewControllerに設定すると、
|
2
|
+
|
2
|
-
|
3
|
+
『0x109ec616b <+43>: movq %rdi, -0x68(%rbp)』という表示の横にThread1:breakpoint1.1というものが表示され、実行ができなくなります。
|
4
|
+
|
3
|
-
|
5
|
+
どのように原因を特定したらよいでしょうか。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
参考までに、以下にコードを記載しておきます。
|
4
12
|
|
5
13
|
ナビゲーターエリアに
|
6
14
|
|
@@ -10,9 +18,9 @@
|
|
10
18
|
|
11
19
|
|
12
20
|
|
21
|
+
|
22
|
+
|
13
|
-
|
23
|
+
```
|
14
|
-
|
15
|
-
|
16
24
|
|
17
25
|
// ViewController.swift
|
18
26
|
|
@@ -178,9 +186,9 @@
|
|
178
186
|
|
179
187
|
}
|
180
188
|
|
181
|
-
|
189
|
+
```
|
190
|
+
|
182
|
-
|
191
|
+
```
|
183
|
-
|
184
192
|
|
185
193
|
<ここからはCustomTableViewCellのコードです>
|
186
194
|
|
@@ -264,7 +272,7 @@
|
|
264
272
|
|
265
273
|
}
|
266
274
|
|
267
|
-
|
275
|
+
```
|
268
276
|
|
269
277
|
|
270
278
|
|
1
コードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1 +1,277 @@
|
|
1
1
|
コードに問題がなく、エラーも出ないのですが、実行すると何も表示されない。その場合、何が関係しているのでしょうか。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
ナビゲーターエリアに
|
6
|
+
|
7
|
+
画像としてfutako.jpg, yokado.jpg, fran.jpg, zikken.jpgを
|
8
|
+
|
9
|
+
音源としてsound01,sound02,sound03,sound04を追加してあります。
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
以下、コードになります。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
// ViewController.swift
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
import UIKit
|
22
|
+
|
23
|
+
import AVFoundation
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
let imageNames = ["futako.jpg", "yokado.jpg", "fran.jpg", "zikken.jpg"]
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
@IBOutlet weak var tableView: UITableView!
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
let imageTitles = ["イヌ2", "ネコ2", "イヌ1", "イヌ2"]
|
46
|
+
|
47
|
+
var audioPlayer = AVAudioPlayer()
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
let imageDescriptions = [
|
52
|
+
|
53
|
+
"イヌ",
|
54
|
+
|
55
|
+
"ネコ",
|
56
|
+
|
57
|
+
"イヌ",
|
58
|
+
|
59
|
+
"イヌ"
|
60
|
+
|
61
|
+
]
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
override func viewDidLoad() {
|
66
|
+
|
67
|
+
super.viewDidLoad()
|
68
|
+
|
69
|
+
// Do any additional setup after loading the view, typically from a nib.
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
override func didReceiveMemoryWarning() {
|
76
|
+
|
77
|
+
super.didReceiveMemoryWarning()
|
78
|
+
|
79
|
+
// Dispose of any resources that can be recreated.
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
86
|
+
|
87
|
+
return imageNames.count
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell") as! CustomTableViewCell
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
cell.setCell(imageNames[(indexPath as NSIndexPath).row], titleText: imageTitles[(indexPath as NSIndexPath).row], descriptionText: imageDescriptions[(indexPath as NSIndexPath).row])
|
102
|
+
|
103
|
+
cell.index = indexPath
|
104
|
+
|
105
|
+
// cell.delegate = self
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
return cell
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
func selectCellButton(_ index: IndexPath) {
|
116
|
+
|
117
|
+
let fileName = "sound\((index as NSIndexPath).row + 1)"
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
print(fileName)
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
do {
|
126
|
+
|
127
|
+
let filePath = Bundle.main.path(forResource: fileName, ofType: "mp3")
|
128
|
+
|
129
|
+
let audioPath = URL(fileURLWithPath: filePath!)
|
130
|
+
|
131
|
+
audioPlayer = try AVAudioPlayer(contentsOf: audioPath)
|
132
|
+
|
133
|
+
if audioPlayer.prepareToPlay() {
|
134
|
+
|
135
|
+
audioPlayer.play()
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
} catch {
|
140
|
+
|
141
|
+
print("Error")
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
@IBAction func tapButton(_ sender: UIButton) {
|
150
|
+
|
151
|
+
var hoge = sender.superview
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
while(hoge!.isKind(of: UITableViewCell.self) == false) {
|
156
|
+
|
157
|
+
hoge = hoge!.superview
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
let cell = hoge as! UITableViewCell
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
let indexPath = self.tableView.indexPath(for: cell)
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
print(indexPath)
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
// delegate?.selectCellButton(index)
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
<ここからはCustomTableViewCellのコードです>
|
186
|
+
|
187
|
+
// CustomTableViewCell.swift
|
188
|
+
|
189
|
+
import UIKit
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
class CustomTableViewCell: UITableViewCell {
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
@IBOutlet weak var myImageView: UIImageView!
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
@IBOutlet weak var myTitleLabel: UILabel!
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
@IBOutlet weak var myDescriptionLabel: UILabel!
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
@IBOutlet weak var tapButton: UIButton!
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
// weak var delegate: CustomTableViewCellDelegate!
|
226
|
+
|
227
|
+
var index: IndexPath!
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
override func awakeFromNib() {
|
232
|
+
|
233
|
+
super.awakeFromNib()
|
234
|
+
|
235
|
+
// Initialization code
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
override func setSelected(_ selected: Bool, animated: Bool) {
|
242
|
+
|
243
|
+
super.setSelected(selected, animated: animated)
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
// Configure the view for the selected state
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
func setCell(_ imageName: String, titleText: String, descriptionText: String) {
|
254
|
+
|
255
|
+
myImageView.image = UIImage(named: imageName)
|
256
|
+
|
257
|
+
myTitleLabel.text = titleText
|
258
|
+
|
259
|
+
myDescriptionLabel.text = descriptionText
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
|
274
|
+
|
275
|
+
上記のコードを実行すると、Cellのラインは表示されるのですが、
|
276
|
+
|
277
|
+
イメージ、ラベルは表示されず、音を鳴らすこともできません。
|