質問編集履歴

2

追加

2019/02/18 01:32

投稿

amazon_106
amazon_106

スコア50

test CHANGED
File without changes
test CHANGED
@@ -41,3 +41,133 @@
41
41
 
42
42
 
43
43
  ![イメージ説明](c96c51bf0a277ea3aef3cc62e20f89ca.png)
44
+
45
+
46
+
47
+ ```
48
+
49
+
50
+
51
+ import UIKit
52
+
53
+ import Firebase
54
+
55
+
56
+
57
+ // private このファイル内のみアクセルできる 変換予測に出る
58
+
59
+ private let reuseIdentifier = "Cell"
60
+
61
+ private let headerIdentifier = "UserProfileHeader"
62
+
63
+
64
+
65
+ class UserProfileVC: UICollectionViewController, UICollectionViewDelegateFlowLayout, UserProfileHeaderDelegate {
66
+
67
+
68
+
69
+ // MARK: - Properties
70
+
71
+
72
+
73
+ // オプショナル型でnilを許可してるのは、新しいコントローラがロードされる時、ユーザーは設定されていないから(下のfetchCurrentUserDataで取得される)
74
+
75
+
76
+
77
+ var currentUser: User?
78
+
79
+
80
+
81
+ //SearchVCのセルをタップした時、タップしたユーザーのProfileVCに遷移するように User.swiftを関連し、ユーザー情報を取得する
82
+
83
+ // SearchVCからProfileVCに画面遷移した時、ロードするユーザー情報
84
+
85
+ var userToLoadFromSearchVC: User?
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+ override func viewDidLoad() {
94
+
95
+ super.viewDidLimport UIKit
96
+
97
+ import Firebase
98
+
99
+
100
+
101
+ // private このファイル内のみアクセルできる 変換予測に出る
102
+
103
+ private let reuseIdentifier = "Cell"
104
+
105
+ private let headerIdentifier = "UserProfileHeader"
106
+
107
+
108
+
109
+ class UserProfileVC: UICollectionViewController, UICollectionViewDelegateFlowLayout, UserProfileHeaderDelegate {
110
+
111
+
112
+
113
+ // MARK: - Properties
114
+
115
+
116
+
117
+ // オプショナル型でnilを許可してるのは、新しいコントローラがロードされる時、ユーザーは設定されていないから(下のfetchCurrentUserDataで取得される)
118
+
119
+
120
+
121
+ var currentUser: User?
122
+
123
+
124
+
125
+ //SearchVCのセルをタップした時、タップしたユーザーのProfileVCに遷移するように User.swiftを関連し、ユーザー情報を取得する
126
+
127
+ // SearchVCからProfileVCに画面遷移した時、ロードするユーザー情報oad()
128
+
129
+
130
+
131
+ // Uncomment the following line to preserve selection between presentations
132
+
133
+ // self.clearsSelectionOnViewWillAppear = false
134
+
135
+
136
+
137
+ // Register cell classes
138
+
139
+ //collectionViewで使用するセルを登録
140
+
141
+ // forCellWithReuseIdentifier セルの再利用識別子 reuseIdentifier(任意の値)を
142
+
143
+ // 新しいコレクションビューセルを作成するために使用するクラスを登録
144
+
145
+ self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
146
+
147
+
148
+
149
+ // profileページのためにセルにしたいファイルを登録
150
+
151
+ self.collectionView!.register(UserProfileHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerIdentifier)
152
+
153
+
154
+
155
+ // 背景色
156
+
157
+ self.collectionView.backgroundColor = .white
158
+
159
+
160
+
161
+ // profileVCのタブを開く時、
162
+
163
+ if userToLoadFromSearchVC == nil {
164
+
165
+ fetchCurrentUserData()
166
+
167
+ }
168
+
169
+
170
+
171
+ }
172
+
173
+ ```

1

追加

2019/02/18 01:32

投稿

amazon_106
amazon_106

スコア50

test CHANGED
File without changes
test CHANGED
@@ -32,8 +32,12 @@
32
32
 
33
33
 
34
34
 
35
- jump先
36
35
 
37
- ```class UserProfileVC: UICollectionViewController, UICollectionViewDelegateFlowLayout
38
36
 
37
+
38
+
39
- ```
39
+ ![イメージ説明](af3bb70d13b8da34416d693567e72167.png)
40
+
41
+
42
+
43
+ ![イメージ説明](c96c51bf0a277ea3aef3cc62e20f89ca.png)