質問編集履歴

8

修正

2016/12/27 14:56

投稿

minoossp
minoossp

スコア42

test CHANGED
File without changes
test CHANGED
@@ -252,7 +252,7 @@
252
252
 
253
253
  // ScrollViewの設定.
254
254
 
255
- scrollView = UIScrollView(frame: CGRect(x: width, y: height, width: width, height: height - barHeight))
255
+ scrollView = UIScrollView(frame: CGRect(x: 0, y: barHeight, width: width, height: height - barHeight))
256
256
 
257
257
  scrollView.showsHorizontalScrollIndicator = false;
258
258
 
@@ -272,7 +272,7 @@
272
272
 
273
273
 
274
274
 
275
- let tableView: UITableView = UITableView(frame: CGRect(x: CGFloat(i) * width, y: height, width: width, height: height - barHeight))
275
+ let tableView: UITableView = UITableView(frame: CGRect(x: CGFloat(i) * width, y: barHeight, width: width, height: height - barHeight))
276
276
 
277
277
  tableView.estimatedRowHeight = 60
278
278
 

7

修正

2016/12/27 14:56

投稿

minoossp
minoossp

スコア42

test CHANGED
File without changes
test CHANGED
@@ -34,17 +34,7 @@
34
34
 
35
35
  追加情報
36
36
 
37
- サンプルは自作でswift3動作確認済み
37
+
38
-
39
- テーブルビューはコードのみで書いています。
40
-
41
- ストーリーボードは初期のままです
42
-
43
-
44
-
45
-
46
-
47
- テーブルビューの生成部分です
48
38
 
49
39
  ```
50
40
 

6

修正

2016/12/27 14:00

投稿

minoossp
minoossp

スコア42

test CHANGED
File without changes
test CHANGED
@@ -66,30 +66,14 @@
66
66
 
67
67
  // テーブルページ数
68
68
 
69
- //////////////////////////////////////////////////////
70
-
71
- //////////////////////////////////////////////////////
72
-
73
69
  var teburupejicount:Int = 0//テーブルセルの押された値
74
70
 
75
- //////////////////////////////////////////////////////
76
-
77
- //////////////////////////////////////////////////////
78
-
79
71
 
80
72
 
81
73
  // テーブルページ表示されているページ
82
74
 
83
- //////////////////////////////////////////////////////
84
-
85
- //////////////////////////////////////////////////////
86
-
87
75
  var teburupejihyoujicount:Int = 0//表示されているページ
88
76
 
89
- //////////////////////////////////////////////////////
90
-
91
- //////////////////////////////////////////////////////
92
-
93
77
  var indexcount:Int = 0//インデックスの値
94
78
 
95
79
 
@@ -104,20 +88,12 @@
104
88
 
105
89
  // テーブルデータ
106
90
 
107
- //////////////////////////////////////////////////////
108
-
109
- //////////////////////////////////////////////////////
110
-
111
91
  var serutaitoru = [[String]]()//セル内のタイトル
112
92
 
113
93
  var seruhituke = [[String]]()//セル内の日付
114
94
 
115
95
 
116
96
 
117
- //////////////////////////////////////////////////////
118
-
119
- //////////////////////////////////////////////////////
120
-
121
97
 
122
98
 
123
99
  override func viewDidLoad() {
@@ -210,20 +186,12 @@
210
186
 
211
187
  }
212
188
 
213
- //////////////////////////////////////////////////////
214
-
215
- //////////////////////////////////////////////////////
216
-
217
189
 
218
190
 
219
191
  // ステータスバーの幅
220
192
 
221
- //////////////////////////////////////////////////////
222
-
223
193
  var barHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
224
194
 
225
- //////////////////////////////////////////////////////
226
-
227
195
 
228
196
 
229
197
  var width:CGFloat = 0
@@ -292,10 +260,6 @@
292
260
 
293
261
  // スクロールビュー
294
262
 
295
- //////////////////////////////////////////////////////
296
-
297
- //////////////////////////////////////////////////////
298
-
299
263
  // ScrollViewの設定.
300
264
 
301
265
  scrollView = UIScrollView(frame: CGRect(x: width, y: height, width: width, height: height - barHeight))
@@ -312,8 +276,6 @@
312
276
 
313
277
  self.view.addSubview(scrollView)
314
278
 
315
- //////////////////////////////////////////////////////
316
-
317
279
 
318
280
 
319
281
  for i in 0 ..< pageSize {
@@ -354,20 +316,12 @@
354
316
 
355
317
  }
356
318
 
357
- //////////////////////////////////////////////////////
358
-
359
- //////////////////////////////////////////////////////
360
-
361
319
 
362
320
 
363
321
 
364
322
 
365
323
  // セルがタップされた時遷移される
366
324
 
367
- //////////////////////////////////////////////////////
368
-
369
- //////////////////////////////////////////////////////
370
-
371
325
 
372
326
 
373
327
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
@@ -378,27 +332,19 @@
378
332
 
379
333
 
380
334
 
381
- //////////////////////////////////////////////////////
335
+
382
-
383
- //////////////////////////////////////////////////////
336
+
384
-
385
-
386
-
387
-
388
-
389
-
390
-
391
-
392
-
393
-
394
-
395
-
396
-
397
-
398
-
399
- //////////////////////////////////////////////////////
337
+
400
-
401
- //////////////////////////////////////////////////////
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
402
348
 
403
349
 
404
350
 
@@ -438,20 +384,12 @@
438
384
 
439
385
  }
440
386
 
441
- //////////////////////////////////////////////////////
442
-
443
- //////////////////////////////////////////////////////
444
-
445
387
 
446
388
 
447
389
 
448
390
 
449
391
  // セルに値を設定するデータソースメソッド(必須)
450
392
 
451
- //////////////////////////////////////////////////////
452
-
453
- //////////////////////////////////////////////////////
454
-
455
393
 
456
394
 
457
395
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -466,8 +404,6 @@
466
404
 
467
405
 
468
406
 
469
- //////////////////////////////////////////////////////
470
-
471
407
  // 配列の中身をすべて各セルに表示させる
472
408
 
473
409
  cell.Label1.text = serutaitoru[tableView.tag][indexPath.row]

5

修正

2016/12/27 13:45

投稿

minoossp
minoossp

スコア42

test CHANGED
File without changes
test CHANGED
@@ -48,9 +48,253 @@
48
48
 
49
49
  ```
50
50
 
51
+
52
+
53
+ import UIKit
54
+
55
+
56
+
57
+ class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UIToolbarDelegate,UIScrollViewDelegate {
58
+
59
+
60
+
61
+
62
+
63
+ @IBOutlet weak var scrollview: UIScrollView!
64
+
65
+
66
+
67
+ // テーブルページ数
68
+
69
+ //////////////////////////////////////////////////////
70
+
71
+ //////////////////////////////////////////////////////
72
+
73
+ var teburupejicount:Int = 0//テーブルセルの押された値
74
+
75
+ //////////////////////////////////////////////////////
76
+
77
+ //////////////////////////////////////////////////////
78
+
79
+
80
+
81
+ // テーブルページ表示されているページ
82
+
83
+ //////////////////////////////////////////////////////
84
+
85
+ //////////////////////////////////////////////////////
86
+
87
+ var teburupejihyoujicount:Int = 0//表示されているページ
88
+
89
+ //////////////////////////////////////////////////////
90
+
91
+ //////////////////////////////////////////////////////
92
+
93
+ var indexcount:Int = 0//インデックスの値
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ var myTableView: [UITableView] = []
102
+
103
+
104
+
105
+ // テーブルデータ
106
+
107
+ //////////////////////////////////////////////////////
108
+
109
+ //////////////////////////////////////////////////////
110
+
111
+ var serutaitoru = [[String]]()//セル内のタイトル
112
+
113
+ var seruhituke = [[String]]()//セル内の日付
114
+
115
+
116
+
117
+ //////////////////////////////////////////////////////
118
+
119
+ //////////////////////////////////////////////////////
120
+
121
+
122
+
123
+ override func viewDidLoad() {
124
+
125
+ super.viewDidLoad()
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ }
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ /*
144
+
145
+ ScrollViewが移動した際に呼ばれる.
146
+
147
+ */
148
+
149
+ func scrollViewDidScroll(_ scrollView: UIScrollView) {
150
+
151
+ // スクロール中の処理
152
+
153
+ print("\(scrollView.contentOffset.x)")
154
+
155
+ print("didScroll")
156
+
157
+ }
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+ func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
166
+
167
+
168
+
169
+ if fmod(scrollView.contentOffset.x, scrollView.frame.maxX) == 0 {
170
+
171
+
172
+
173
+ }else if scrollview.contentOffset.x == self.view.frame.width{
174
+
175
+
176
+
177
+ }else{
178
+
179
+ print(teburupejicount)
180
+
181
+
182
+
183
+ }
184
+
185
+
186
+
187
+ print("teburupejicount \(teburupejicount)")
188
+
189
+ print("teburupejihyoujicount \(teburupejihyoujicount)")
190
+
191
+ print(teburupejicount)
192
+
193
+
194
+
195
+
196
+
197
+ }
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+ // セルのスイッチ
206
+
207
+ internal func onClickMySwicth(sender: UISwitch){
208
+
209
+
210
+
211
+ }
212
+
213
+ //////////////////////////////////////////////////////
214
+
215
+ //////////////////////////////////////////////////////
216
+
217
+
218
+
219
+ // ステータスバーの幅
220
+
221
+ //////////////////////////////////////////////////////
222
+
223
+ var barHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
224
+
225
+ //////////////////////////////////////////////////////
226
+
227
+
228
+
229
+ var width:CGFloat = 0
230
+
231
+ var height:CGFloat = 0
232
+
233
+
234
+
235
+
236
+
237
+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
238
+
239
+ return 60
240
+
241
+ }
242
+
243
+
244
+
245
+ // UIScrollView.
246
+
247
+ var scrollView: UIScrollView!
248
+
249
+
250
+
251
+ // ページ番号.
252
+
253
+ let pageSize = 2
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+ override func viewWillAppear(_ animated: Bool) {
262
+
263
+ super.viewWillAppear(animated)
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+ serutaitoru = [["ご飯", "味噌汁", "焼き魚"],["天津飯", "チャーハン", "八宝菜", "酢豚", "肉まん"]]
272
+
273
+
274
+
275
+
276
+
277
+ seruhituke = [["1980/2/27", "1983/8/25", "2016/10/10"],["2016/6/24", "2014/12/16", "2014/8/16", "2014/11/16", "2018/12/3"]]
278
+
279
+
280
+
281
+
282
+
283
+ width = CGFloat(self.view.frame.maxX)
284
+
285
+ height = CGFloat(self.view.frame.maxY)
286
+
287
+ // Status Barの高さを取得.
288
+
289
+ let barHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
290
+
291
+
292
+
51
293
  // スクロールビュー
52
294
 
53
-
295
+ //////////////////////////////////////////////////////
296
+
297
+ //////////////////////////////////////////////////////
54
298
 
55
299
  // ScrollViewの設定.
56
300
 
@@ -68,7 +312,7 @@
68
312
 
69
313
  self.view.addSubview(scrollView)
70
314
 
71
-
315
+ //////////////////////////////////////////////////////
72
316
 
73
317
 
74
318
 
@@ -88,7 +332,7 @@
88
332
 
89
333
  tableView.delegate = self
90
334
 
91
- tableView.register(UINib(nibName: "TableViewCelll", bundle: nil), forCellReuseIdentifier: "MyCell")
335
+ tableView.register(UINib(nibName: "TableViewCell", bundle: nil), forCellReuseIdentifier: "MyCell")
92
336
 
93
337
  myTableView.append(tableView)
94
338
 
@@ -98,12 +342,152 @@
98
342
 
99
343
 
100
344
 
101
- print("テーブル\(i)")
345
+ print("テーブル\(i)")
102
346
 
103
347
  }
104
348
 
105
349
 
106
350
 
351
+ print("myTableView[]: \(myTableView)")
352
+
353
+
354
+
355
+ }
356
+
357
+ //////////////////////////////////////////////////////
358
+
359
+ //////////////////////////////////////////////////////
360
+
361
+
362
+
363
+
364
+
365
+ // セルがタップされた時遷移される
366
+
367
+ //////////////////////////////////////////////////////
368
+
369
+ //////////////////////////////////////////////////////
370
+
371
+
372
+
373
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
374
+
375
+
376
+
377
+ }
378
+
379
+
380
+
381
+ //////////////////////////////////////////////////////
382
+
383
+ //////////////////////////////////////////////////////
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+ //////////////////////////////////////////////////////
400
+
401
+ //////////////////////////////////////////////////////
402
+
403
+
404
+
405
+ override func didReceiveMemoryWarning() {
406
+
407
+ super.didReceiveMemoryWarning()
408
+
409
+ }
410
+
411
+ func numberOfSections(in tableView: UITableView) -> Int {
412
+
413
+ return 1
414
+
415
+ }
416
+
417
+
418
+
419
+
420
+
421
+ // セルの個数を指定するデリゲートメソッド(必須)
422
+
423
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
424
+
425
+ if tableView.tag == 0 {
426
+
427
+ return serutaitoru[0].count
428
+
429
+ }else if tableView.tag == 1 {
430
+
431
+ return serutaitoru[1].count
432
+
433
+ }else{
434
+
435
+ return 0
436
+
437
+ }
438
+
439
+ }
440
+
441
+ //////////////////////////////////////////////////////
442
+
443
+ //////////////////////////////////////////////////////
444
+
445
+
446
+
447
+
448
+
449
+ // セルに値を設定するデータソースメソッド(必須)
450
+
451
+ //////////////////////////////////////////////////////
452
+
453
+ //////////////////////////////////////////////////////
454
+
455
+
456
+
457
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
458
+
459
+
460
+
461
+
462
+
463
+ let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath) as! TableViewCell
464
+
465
+
466
+
467
+
468
+
469
+ //////////////////////////////////////////////////////
470
+
471
+ // 配列の中身をすべて各セルに表示させる
472
+
473
+ cell.Label1.text = serutaitoru[tableView.tag][indexPath.row]
474
+
475
+ cell.Label2.text = seruhituke[tableView.tag][indexPath.row]
476
+
477
+
478
+
479
+
480
+
481
+ return cell
482
+
483
+
484
+
485
+ }
486
+
487
+ }
488
+
489
+
490
+
107
491
  ```
108
492
 
109
493
 

4

追加

2016/12/27 13:37

投稿

minoossp
minoossp

スコア42

test CHANGED
File without changes
test CHANGED
@@ -44,6 +44,70 @@
44
44
 
45
45
 
46
46
 
47
+ テーブルビューの生成部分です
48
+
49
+ ```
50
+
51
+ // スクロールビュー
52
+
53
+
54
+
55
+ // ScrollViewの設定.
56
+
57
+ scrollView = UIScrollView(frame: CGRect(x: width, y: height, width: width, height: height - barHeight))
58
+
59
+ scrollView.showsHorizontalScrollIndicator = false;
60
+
61
+ scrollView.showsVerticalScrollIndicator = false
62
+
63
+ scrollView.isPagingEnabled = true
64
+
65
+ scrollView.delegate = self
66
+
67
+ scrollView.contentSize = CGSize(width:CGFloat(pageSize) * width, height:0)
68
+
69
+ self.view.addSubview(scrollView)
70
+
71
+
72
+
73
+
74
+
75
+ for i in 0 ..< pageSize {
76
+
77
+
78
+
79
+ let tableView: UITableView = UITableView(frame: CGRect(x: CGFloat(i) * width, y: height, width: width, height: height - barHeight))
80
+
81
+ tableView.estimatedRowHeight = 60
82
+
83
+ tableView.rowHeight = UITableViewAutomaticDimension
84
+
85
+ tableView.tag = i
86
+
87
+ tableView.dataSource = self
88
+
89
+ tableView.delegate = self
90
+
91
+ tableView.register(UINib(nibName: "TableViewCelll", bundle: nil), forCellReuseIdentifier: "MyCell")
92
+
93
+ myTableView.append(tableView)
94
+
95
+
96
+
97
+ scrollView.addSubview(myTableView[i])
98
+
99
+
100
+
101
+ print("テーブル\(i)")
102
+
103
+ }
104
+
105
+
106
+
107
+ ```
108
+
109
+
110
+
47
111
 
48
112
 
49
113
  swift3.0 xcode8.1 beta

3

修正

2016/12/27 08:46

投稿

minoossp
minoossp

スコア42

test CHANGED
File without changes
test CHANGED
@@ -36,6 +36,8 @@
36
36
 
37
37
  サンプルは自作でswift3動作確認済み
38
38
 
39
+ テーブルビューはコードのみで書いています。
40
+
39
41
  ストーリーボードは初期のままです
40
42
 
41
43
 

2

修正

2016/12/27 07:51

投稿

minoossp
minoossp

スコア42

test CHANGED
File without changes
test CHANGED
@@ -44,4 +44,4 @@
44
44
 
45
45
 
46
46
 
47
- swift3.0 xcode8.3
47
+ swift3.0 xcode8.1 beta

1

追加

2016/12/27 07:42

投稿

minoossp
minoossp

スコア42

test CHANGED
File without changes
test CHANGED
@@ -32,6 +32,16 @@
32
32
 
33
33
 
34
34
 
35
+ 追加情報
36
+
37
+ サンプルは自作でswift3動作確認済み
38
+
39
+ ストーリーボードは初期のままです
40
+
41
+
42
+
43
+
44
+
35
45
 
36
46
 
37
47
  swift3.0 xcode8.3