teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

6

内容修正

2017/08/04 08:32

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -41,7 +41,7 @@
41
41
  guard let cell = table.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? Headcell else {
42
42
  fatalError("Your cellIdentifier is invalid")
43
43
  }
44
- cell.layoutWithData(head_img[0])
44
+ cell.data(head_img[0])
45
45
 
46
46
 
47
47
 

5

内容修正

2017/08/04 08:32

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -86,7 +86,7 @@
86
86
 
87
87
  return cell
88
88
  }else{
89
- guard let cell = table.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? Lpcell else {
89
+ guard let cell = table.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? Headcell else {
90
90
  fatalError("Your cellIdentifier is invalid")
91
91
  }
92
92
 

4

本文内容の詳細を変更しました

2017/08/04 08:29

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -29,4 +29,89 @@
29
29
  }
30
30
  ```
31
31
  else if section==1〜section == 5以降までの部分をループなどで対応したいのですが、
32
- エラーなどで出来ません。どのように解決すれば良いでしょうか??
32
+ エラーなどで出来ません。どのように解決すれば良いでしょうか??
33
+
34
+ 具体的には
35
+ ```
36
+ func tableView(_ table: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
37
+
38
+
39
+
40
+ if indexPath.section == 0 {
41
+ guard let cell = table.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? Headcell else {
42
+ fatalError("Your cellIdentifier is invalid")
43
+ }
44
+ cell.layoutWithData(head_img[0])
45
+
46
+
47
+
48
+ return cell
49
+
50
+ }else if indexPath.section == 1{
51
+ guard let cell = table.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? Headcell else {
52
+ fatalError("Your cellIdentifier is invalid")
53
+ }
54
+
55
+ guard self.banner.count != 0 else {
56
+ return cell
57
+ }
58
+
59
+
60
+
61
+ if self.status[0] == 1000 {
62
+ cell.data(self.state[0])
63
+ }else if self.status[0] == 1001{
64
+ cell.data(self.state2[0])
65
+ }
66
+
67
+
68
+ return cell
69
+ }else if indexPath.section == 2{
70
+ guard let cell = table.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? Headcell else {
71
+ fatalError("Your cellIdentifier is invalid")
72
+ }
73
+
74
+ guard self.banner.count != 0 else {
75
+ return cell
76
+ }
77
+
78
+
79
+
80
+ if self.status[1] == 1000 {
81
+ cell.data(self.state[1])
82
+ }else if self.status[1] == 1001{
83
+ cell.data(self.state2[1])
84
+ }
85
+
86
+
87
+ return cell
88
+ }else{
89
+ guard let cell = table.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? Lpcell else {
90
+ fatalError("Your cellIdentifier is invalid")
91
+ }
92
+
93
+ guard self.banner.count != 0 else {
94
+ return cell
95
+ }
96
+
97
+
98
+
99
+ if self.status[2] == 1000 {
100
+ cell.data(self.state[2])
101
+ }else if self.status[2] == 1001{
102
+ cell.data(self.state2[2])
103
+ }
104
+
105
+
106
+ return cell
107
+ }
108
+
109
+ }
110
+ class Headcell: UITableViewCell {
111
+ @IBOutlet weak var head: UIImageView!
112
+ func data(_ img:UIImage) {
113
+ head.image = img
114
+
115
+ }
116
+ }
117
+ ```

3

内容分もretunの値変更により変更

2017/08/04 08:28

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -28,5 +28,5 @@
28
28
  }
29
29
  }
30
30
  ```
31
- else if section==〜section == 5までの部分をループなどで対応したいのですが、
31
+ else if section==1〜section == 5以降までの部分をループなどで対応したいのですが、
32
32
  エラーなどで出来ません。どのように解決すれば良いでしょうか??

2

return 値修正

2017/08/04 07:22

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -12,7 +12,7 @@
12
12
  ```
13
13
  func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
14
14
  if section == 0 {
15
- return 5
15
+ return 10
16
16
  }else if section == 1 {
17
17
  return 5
18
18
  }else if section == 2 {
@@ -24,7 +24,7 @@
24
24
  }else if section == 5{
25
25
  return 5
26
26
  }else{
27
- return 30
27
+ return 5
28
28
  }
29
29
  }
30
30
  ```

1

returnの値を変更しました。

2017/08/04 07:21

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -2,7 +2,7 @@
2
2
  ```
3
3
  func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
4
4
  if section == 0 {
5
- return 0
5
+ return 5
6
6
  }else{
7
7
  return 30
8
8
  }
@@ -12,11 +12,11 @@
12
12
  ```
13
13
  func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
14
14
  if section == 0 {
15
- return 0
15
+ return 5
16
16
  }else if section == 1 {
17
- return 20
17
+ return 5
18
18
  }else if section == 2 {
19
- return 10
19
+ return 5
20
20
  }else if section == 3 {
21
21
  return 5
22
22
  }else if section == 4 {