質問編集履歴
2
参考事項として現状のスクリーンショットを添付しました。字数制限があるので、前回掲載のコードと画像は削除しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -262,184 +262,16 @@
|
|
262
262
|
|
263
263
|
|
264
264
|
|
265
|
-
###その後の参考事項⇨
|
265
|
+
###その後の参考事項⇨
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
266
|
+
|
270
|
-
|
271
|
-
// Lesson03m
|
272
|
-
|
273
|
-
//
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
import UIKit
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
class ViewController: UIViewController , UITableViewDataSource, UITableViewDelegate{
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
@IBOutlet var table:UITableView!
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
let imgArray: NSArray = ["VideoCut.jpg",
|
292
|
-
|
293
|
-
"VideoCut.jpg",
|
294
|
-
|
295
|
-
"VideoCut.jpg",
|
296
|
-
|
297
|
-
"Book.jpg",
|
298
|
-
|
299
|
-
"Book.jpg",
|
300
|
-
|
301
|
-
"Book.jpg",
|
302
|
-
|
303
|
-
"Book.jpg",
|
304
|
-
|
305
|
-
"VideoCut.jpg"]
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
let label2Array: NSArray = ["2013/8/23/16:04","2013/8/23/16:15","2013/8/23/16:47","2013/8/23/17:10",
|
312
|
-
|
313
|
-
"2013/8/23/1715:","2013/8/23/17:21","2013/8/23/17:33","2013/8/23/17:41"]
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
override func viewDidLoad() {
|
318
|
-
|
319
|
-
super.viewDidLoad()
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
//Table Viewのセルの数を指定
|
326
|
-
|
327
|
-
func tableView(table: UITableView, numberOfRowsInSection section: Int) -> Int {
|
328
|
-
|
329
|
-
return imgArray.count
|
330
|
-
|
331
|
-
}
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
//各セルの要素を設定する
|
336
|
-
|
337
|
-
func tableView(table: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
// tableCell の ID で UITableViewCell のインスタンスを生成
|
342
|
-
|
343
|
-
let cell = table.dequeueReusableCellWithIdentifier("tableCell", forIndexPath: indexPath)
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
let img = UIImage(named:"\(imgArray[indexPath.row])")
|
348
|
-
|
349
|
-
|
267
|
+
既存のコードをコメントアウトし、ネットのコードをそっくり導入の上テキストとイメージファイルを
|
350
|
-
|
351
|
-
|
268
|
+
|
352
|
-
|
353
|
-
imageView.image = img
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
// Tag番号 2 で UILabel インスタンスの生成
|
358
|
-
|
359
|
-
let label1 = table.viewWithTag(2) as! UILabel
|
360
|
-
|
361
|
-
label1.text = "No.\(indexPath.row + 1)"
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
// Tag番号 3 で UILabel インスタンスの生成
|
366
|
-
|
367
|
-
let label2 = table.viewWithTag(3) as! UILabel
|
368
|
-
|
369
|
-
label2.text = "\(label2Array[indexPath.row])"
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
return cell
|
376
|
-
|
377
|
-
}
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
// // 文字色変更
|
384
|
-
|
385
|
-
// cell.textLabel?.textColor = UIColor.blackColor()
|
386
|
-
|
387
|
-
//
|
388
|
-
|
389
|
-
|
269
|
+
書き換えましたら、下記の画像スクリーンショットのごとき画面になりました。
|
390
|
-
|
391
|
-
|
270
|
+
|
392
|
-
|
393
|
-
// // 文字を太字に変更
|
394
|
-
|
395
|
-
// cell.textLabel?.font = UIFont.boldSystemFontOfSize(24)
|
396
|
-
|
397
|
-
//
|
398
|
-
|
399
|
-
//
|
400
|
-
|
401
|
-
//
|
402
|
-
|
403
|
-
|
271
|
+
あとは、体裁を整え遷移を以前の機能がでるように書き換えれば完成かと思います。
|
404
|
-
|
405
|
-
|
272
|
+
|
406
|
-
|
407
|
-
|
273
|
+
|
408
|
-
|
409
|
-
|
274
|
+
|
410
|
-
|
411
|
-
|
275
|
+
|
412
|
-
|
413
|
-
|
276
|
+
|
414
|
-
|
415
|
-
// //cell.accessoryType = UITableViewCellAccessoryType.Checkmark
|
416
|
-
|
417
|
-
// return cell
|
418
|
-
|
419
|
-
//
|
420
|
-
|
421
|
-
//}
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
override func didReceiveMemoryWarning() {
|
426
|
-
|
427
|
-
super.didReceiveMemoryWarning()
|
428
|
-
|
429
|
-
}
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
}
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
```
|
440
|
-
|
441
|
-
![![イメージ説明](3ac2cbcfbd77ef205803916119915c91.png)](a5a3ea628fc8441b2f6059b9be1ff394.png)
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
![イメージ説明](
|
277
|
+
![イメージ説明](a4466ea9e646ed8734a5432034f03df7.png)
|
1
末尾に対策のコードと画像スクリーンショット2枚追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -259,3 +259,187 @@
|
|
259
259
|
テキストに沢山のエラーが発生し収拾がつかなくなりましたので、テキストは従来どおりの
|
260
260
|
|
261
261
|
設定にして、イメージのみ追記設定にしましたら上記どおりビルド成功までできました。
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
###その後の参考事項⇨コードと画像スクリーンショット2枚
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
```// ViewController.swift
|
270
|
+
|
271
|
+
// Lesson03m
|
272
|
+
|
273
|
+
//
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
import UIKit
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
class ViewController: UIViewController , UITableViewDataSource, UITableViewDelegate{
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
@IBOutlet var table:UITableView!
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
let imgArray: NSArray = ["VideoCut.jpg",
|
292
|
+
|
293
|
+
"VideoCut.jpg",
|
294
|
+
|
295
|
+
"VideoCut.jpg",
|
296
|
+
|
297
|
+
"Book.jpg",
|
298
|
+
|
299
|
+
"Book.jpg",
|
300
|
+
|
301
|
+
"Book.jpg",
|
302
|
+
|
303
|
+
"Book.jpg",
|
304
|
+
|
305
|
+
"VideoCut.jpg"]
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
let label2Array: NSArray = ["2013/8/23/16:04","2013/8/23/16:15","2013/8/23/16:47","2013/8/23/17:10",
|
312
|
+
|
313
|
+
"2013/8/23/1715:","2013/8/23/17:21","2013/8/23/17:33","2013/8/23/17:41"]
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
override func viewDidLoad() {
|
318
|
+
|
319
|
+
super.viewDidLoad()
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
//Table Viewのセルの数を指定
|
326
|
+
|
327
|
+
func tableView(table: UITableView, numberOfRowsInSection section: Int) -> Int {
|
328
|
+
|
329
|
+
return imgArray.count
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
//各セルの要素を設定する
|
336
|
+
|
337
|
+
func tableView(table: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
// tableCell の ID で UITableViewCell のインスタンスを生成
|
342
|
+
|
343
|
+
let cell = table.dequeueReusableCellWithIdentifier("tableCell", forIndexPath: indexPath)
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
let img = UIImage(named:"\(imgArray[indexPath.row])")
|
348
|
+
|
349
|
+
// Tag番号 1 で UIImageView インスタンスの生成
|
350
|
+
|
351
|
+
let imageView = table.viewWithTag(1) as! UIImageView
|
352
|
+
|
353
|
+
imageView.image = img
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
// Tag番号 2 で UILabel インスタンスの生成
|
358
|
+
|
359
|
+
let label1 = table.viewWithTag(2) as! UILabel
|
360
|
+
|
361
|
+
label1.text = "No.\(indexPath.row + 1)"
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
// Tag番号 3 で UILabel インスタンスの生成
|
366
|
+
|
367
|
+
let label2 = table.viewWithTag(3) as! UILabel
|
368
|
+
|
369
|
+
label2.text = "\(label2Array[indexPath.row])"
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
return cell
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
// // 文字色変更
|
384
|
+
|
385
|
+
// cell.textLabel?.textColor = UIColor.blackColor()
|
386
|
+
|
387
|
+
//
|
388
|
+
|
389
|
+
// // 文字サイズ変更
|
390
|
+
|
391
|
+
// //cell.textLabel?.font = UIFont.systemFontOfSize(30)
|
392
|
+
|
393
|
+
// // 文字を太字に変更
|
394
|
+
|
395
|
+
// cell.textLabel?.font = UIFont.boldSystemFontOfSize(24)
|
396
|
+
|
397
|
+
//
|
398
|
+
|
399
|
+
//
|
400
|
+
|
401
|
+
//
|
402
|
+
|
403
|
+
// // cellの背景を透過
|
404
|
+
|
405
|
+
// cell.backgroundColor = UIColor.whiteColor()
|
406
|
+
|
407
|
+
// // cell内のcontentViewの背景を透過
|
408
|
+
|
409
|
+
// //cell.contentView.backgroundColor = UIColor.whiteColor()
|
410
|
+
|
411
|
+
//
|
412
|
+
|
413
|
+
// // チェックマークをつける
|
414
|
+
|
415
|
+
// //cell.accessoryType = UITableViewCellAccessoryType.Checkmark
|
416
|
+
|
417
|
+
// return cell
|
418
|
+
|
419
|
+
//
|
420
|
+
|
421
|
+
//}
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
override func didReceiveMemoryWarning() {
|
426
|
+
|
427
|
+
super.didReceiveMemoryWarning()
|
428
|
+
|
429
|
+
}
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
}
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
```
|
440
|
+
|
441
|
+
![![イメージ説明](3ac2cbcfbd77ef205803916119915c91.png)](a5a3ea628fc8441b2f6059b9be1ff394.png)
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
![イメージ説明](b3d8b79873481571b81f99e7e1628c96.png)
|