質問編集履歴
6
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -220,4 +220,4 @@
|
|
220
220
|
|
221
221
|
Xibの制約
|
222
222
|
|
223
|
-
![イメージ説明](
|
223
|
+
![イメージ説明](1c4eda10285de179f07f11cfd79dba7e.png)
|
5
制約を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -220,4 +220,4 @@
|
|
220
220
|
|
221
221
|
Xibの制約
|
222
222
|
|
223
|
-
![イメージ説明](7
|
223
|
+
![イメージ説明](7b9571d57fec168a88ea66f6f5361292.png)
|
4
制約を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -218,6 +218,6 @@
|
|
218
218
|
|
219
219
|
|
220
220
|
|
221
|
-
Xib
|
221
|
+
Xibの制約
|
222
|
-
|
222
|
+
|
223
|
-
![イメージ説明](
|
223
|
+
![イメージ説明](73c7b63a1de9d7db331ec18f08e3f867.png)
|
3
MyPageHeaderViewの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -175,3 +175,49 @@
|
|
175
175
|
|
176
176
|
|
177
177
|
これの原因も原因がわかる方がいればご回答いただけると幸いです。
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
MyPageHeaderViewの詳細
|
184
|
+
|
185
|
+
```swift
|
186
|
+
|
187
|
+
class MyPageHeaderView: UIView {
|
188
|
+
|
189
|
+
@IBOutlet weak var profileImageView: UIImageView!
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
override func awakeFromNib() {
|
194
|
+
|
195
|
+
self.setupProfileImage()
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
func setupProfileImage(){
|
202
|
+
|
203
|
+
profileImageView.layer.cornerRadius = 60
|
204
|
+
|
205
|
+
profileImageView.layer.masksToBounds = true
|
206
|
+
|
207
|
+
profileImageView.layer.borderColor = UIColor.redColor().CGColor
|
208
|
+
|
209
|
+
profileImageView.layer.borderWidth = 2
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
```
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
Xib
|
222
|
+
|
223
|
+
![イメージ説明](453b455132a9a9c01847bd44c23213f4.png)
|
2
新たな問題
test
CHANGED
File without changes
|
test
CHANGED
@@ -143,3 +143,35 @@
|
|
143
143
|
}
|
144
144
|
|
145
145
|
```
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
またsetupTableViewHeader()関数の中身を以下のように
|
152
|
+
|
153
|
+
```swift
|
154
|
+
|
155
|
+
func setupTableViewHeader(){
|
156
|
+
|
157
|
+
let headerView: MyPageHeaderView = UINib(nibName: "MyPageHeader", bundle: nil).instantiateWithOwner(self, options: nil)[0] as! MyPageHeaderView
|
158
|
+
|
159
|
+
headerView.bounds = CGRect(x: 0, y: 0, width: 0, height: 100)
|
160
|
+
|
161
|
+
tableView.tableHeaderView = headerView
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
```
|
168
|
+
|
169
|
+
XiBから読み込む形に書き換えると
|
170
|
+
|
171
|
+
![イメージ説明](f23e9bdfce3fe64f8447248323036ab1.png)
|
172
|
+
|
173
|
+
のように一番うえのCellがTableHeaderViewの下に潜り込んでしまいます。
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
これの原因も原因がわかる方がいればご回答いただけると幸いです。
|
1
ソースコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,3 +15,131 @@
|
|
15
15
|
|
16
16
|
|
17
17
|
どなたか原因を知っている方がいましたら教えていただけると幸いです。
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
ソースコード自体はストーリーボードからtableViewを接続してシンプルに記述しています。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
```swift
|
26
|
+
|
27
|
+
import UIKit
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
class MyPageViewController: UIViewController {
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
@IBOutlet weak var tableView: UITableView!
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
let menuList = ["プロフィールを編集する", "20Questionsに回答する", "アプリの設定", "興味カテゴリの編集"]
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
override func viewDidLoad() {
|
44
|
+
|
45
|
+
super.viewDidLoad()
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
tableView.delegate = self
|
50
|
+
|
51
|
+
tableView.dataSource = self
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
self.setupTableViewHeader()
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
override func didReceiveMemoryWarning() {
|
62
|
+
|
63
|
+
super.didReceiveMemoryWarning()
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
func setupTableViewHeader(){
|
70
|
+
|
71
|
+
tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 150))
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
/**
|
80
|
+
|
81
|
+
* UITableView Datasource
|
82
|
+
|
83
|
+
*/
|
84
|
+
|
85
|
+
extension MyPageViewController: UITableViewDataSource {
|
86
|
+
|
87
|
+
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
88
|
+
|
89
|
+
return menuList.count
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
96
|
+
|
97
|
+
return UIView()
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
104
|
+
|
105
|
+
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Cell")
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
cell.textLabel?.text = menuList[indexPath.row]
|
110
|
+
|
111
|
+
return cell
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
118
|
+
|
119
|
+
return nil
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
/**
|
130
|
+
|
131
|
+
* UITableView Delegate
|
132
|
+
|
133
|
+
*/
|
134
|
+
|
135
|
+
extension MyPageViewController: UITableViewDelegate {
|
136
|
+
|
137
|
+
func tableView(table: UITableView, didSelectRowAtIndexPath indexPath:NSIndexPath) {
|
138
|
+
|
139
|
+
print(menuList[indexPath.row])
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
```
|