質問編集履歴

1

少し見やすくしました

2018/12/11 07:52

投稿

hoo
hoo

スコア12

test CHANGED
File without changes
test CHANGED
@@ -9,84 +9,6 @@
9
9
 
10
10
 
11
11
  ```Swift
12
-
13
-
14
-
15
- class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
16
-
17
-
18
-
19
- // 端末のサイズを取得
20
-
21
- let heightOfUsersIPhone = UIScreen.main.bounds.size.height // 高さ
22
-
23
- let widthOfUsersIPhone = UIScreen.main.bounds.size.width // 横幅
24
-
25
-
26
-
27
- // ステータスバーの高さを取得
28
-
29
- let heightOfStatusBar = UIApplication.shared.statusBarFrame.size.height
30
-
31
-
32
-
33
- override func viewDidLoad() {
34
-
35
- super.viewDidLoad()
36
-
37
-
38
-
39
- // tableViewを表示
40
-
41
- let myTableView = UITableView(frame: CGRect(x: 0, y: 0, width: widthOfUsersIPhone, height: heightOfUsersIPhone-heightOfStatusBar), style: .plain)
42
-
43
- myTableView.rowHeight = 45
44
-
45
- myTableView.delegate = self
46
-
47
- myTableView.dataSource = self
48
-
49
- myTableView.allowsSelection = false
50
-
51
- myTableView.register(CustomCell.self, forCellReuseIdentifier: NSStringFromClass(CustomCell.self))
52
-
53
-
54
-
55
- view.addSubview(myTableView)
56
-
57
-
58
-
59
- }
60
-
61
-
62
-
63
- func numberOfSections(in tableView: UITableView) -> Int {
64
-
65
- return 1
66
-
67
- }
68
-
69
-
70
-
71
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
72
-
73
- return 25
74
-
75
- }
76
-
77
-
78
-
79
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
80
-
81
- let cell = tableView.dequeueReusableCell(withIdentifier: NSStringFromClass(CustomCell.self), for: indexPath) as! CustomCell
82
-
83
-
84
-
85
- return cell
86
-
87
- }
88
-
89
- }
90
12
 
91
13
 
92
14
 
@@ -160,7 +82,71 @@
160
82
 
161
83
  }
162
84
 
85
+ }
163
86
 
87
+
88
+
89
+ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
90
+
91
+
92
+
93
+
94
+
95
+ override func viewDidLoad() {
96
+
97
+ super.viewDidLoad()
98
+
99
+
100
+
101
+ // tableViewを表示
102
+
103
+ let myTableView = UITableView(frame: CGRect(x: 0, y: 0, width: 200, height: 400), style: .plain)
104
+
105
+ myTableView.rowHeight = 45
106
+
107
+ myTableView.delegate = self
108
+
109
+ myTableView.dataSource = self
110
+
111
+ myTableView.allowsSelection = false
112
+
113
+ myTableView.register(CustomCell.self, forCellReuseIdentifier: NSStringFromClass(CustomCell.self))
114
+
115
+
116
+
117
+ view.addSubview(myTableView)
118
+
119
+
120
+
121
+ }
122
+
123
+
124
+
125
+ func numberOfSections(in tableView: UITableView) -> Int {
126
+
127
+ return 1
128
+
129
+ }
130
+
131
+
132
+
133
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
134
+
135
+ return 25
136
+
137
+ }
138
+
139
+
140
+
141
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
142
+
143
+ let cell = tableView.dequeueReusableCell(withIdentifier: NSStringFromClass(CustomCell.self), for: indexPath) as! CustomCell
144
+
145
+
146
+
147
+ return cell
148
+
149
+ }
164
150
 
165
151
  }
166
152