質問編集履歴

8

修正

2019/05/02 10:49

投稿

reeeeet
reeeeet

スコア95

test CHANGED
File without changes
test CHANGED
@@ -228,4 +228,8 @@
228
228
 
229
229
 
230
230
 
231
+ **どうやったら解決できるでしょうか?**
232
+
233
+ **もしくはどこらへんが怪しいでしょうか?**
234
+
231
235
  すみませんが、よろしくお願い致します。

7

修正

2019/05/02 10:49

投稿

reeeeet
reeeeet

スコア95

test CHANGED
File without changes
test CHANGED
@@ -32,9 +32,9 @@
32
32
 
33
33
  ```ここに言語を入力
34
34
 
35
- updateStateFollowBtn()
35
+ updateStateFollowBtn
36
-
36
+
37
- configureFollowBtn()
37
+ configureFollowBtn
38
38
 
39
39
  ```
40
40
 

6

修正

2019/05/02 04:45

投稿

reeeeet
reeeeet

スコア95

test CHANGED
File without changes
test CHANGED
@@ -32,12 +32,6 @@
32
32
 
33
33
  ```ここに言語を入力
34
34
 
35
- 111111
36
-
37
- success2
38
-
39
- success1
40
-
41
35
  updateStateFollowBtn()
42
36
 
43
37
  configureFollowBtn()

5

誤字

2019/05/02 04:44

投稿

reeeeet
reeeeet

スコア95

test CHANGED
File without changes
test CHANGED
@@ -156,7 +156,7 @@
156
156
 
157
157
  func configureFollowBtn() {
158
158
 
159
- followBtn.setTitle("follow", for: .normal)
159
+ followBtn.setTitle("follow", for: .normal)  // <- 反応する
160
160
 
161
161
 
162
162
 
@@ -170,7 +170,7 @@
170
170
 
171
171
  func configureUnFollowBtn() {
172
172
 
173
- followBtn.setTitle("unfollow", for: .normal)
173
+ followBtn.setTitle("unfollow", for: .normal) 
174
174
 
175
175
  followBtn.addTarget(self, action: #selector(self.unFollowAction), for: .touchUpInside)
176
176
 

4

誤字

2019/05/02 04:30

投稿

reeeeet
reeeeet

スコア95

test CHANGED
File without changes
test CHANGED
@@ -20,7 +20,29 @@
20
20
 
21
21
  #storyboard
22
22
 
23
+ ![イメージ説明](a3a587a617f610282b43a8dfcd875ac0.png)
24
+
25
+ ![イメージ説明](5f96d61d5aa82e769f0e0c7baec54d32.png)
26
+
23
- ![イメージ説明](6ef0c8a738ca5f4cfd7ed27c9dfe67a6.png)
27
+ ![イメージ説明](a19382fc7801e3ca25d2c4ad47d73d7b.png)
28
+
29
+
30
+
31
+ # デバックエリア
32
+
33
+ ```ここに言語を入力
34
+
35
+ 111111
36
+
37
+ success2
38
+
39
+ success1
40
+
41
+ updateStateFollowBtn()
42
+
43
+ configureFollowBtn()
44
+
45
+ ```
24
46
 
25
47
 
26
48
 
@@ -34,182 +56,168 @@
34
56
 
35
57
  import UIKit
36
58
 
59
+ class HeaderProfileCollectionViewCell: UICollectionViewCell {
60
+
61
+
62
+
37
- import SDWebImage
63
+ @IBOutlet weak var profileImageView: UIImageView!
38
-
64
+
39
- protocol PeopleTableViewCellDelegate {
65
+ @IBOutlet weak var nameLabel: UILabel!
66
+
40
-
67
+ @IBOutlet weak var myPostsCountLabel: UILabel!
68
+
69
+ @IBOutlet weak var followingCountLabel: UILabel!
70
+
71
+ @IBOutlet weak var followerCountLabel: UILabel!
72
+
73
+ @IBOutlet weak var followBtn: UIButton!
74
+
75
+
76
+
77
+ var user: UserModel? {
78
+
79
+ didSet {
80
+
81
+ updateView()
82
+
83
+ }
84
+
85
+ }
86
+
87
+
88
+
89
+ override func awakeFromNib() {
90
+
91
+ super.awakeFromNib()
92
+
93
+
94
+
95
+ profileImageView.clipsToBounds = true
96
+
97
+ profileImageView.layer.cornerRadius = 50
98
+
99
+
100
+
101
+
102
+
103
+ }
104
+
105
+
106
+
107
+ func updateView() {
108
+
109
+ self.nameLabel.text = user!.username
110
+
111
+ if let profilePhotoUrlString = user!.profileImageURL {
112
+
113
+ let profilePhotoUrl = URL(string: profilePhotoUrlString)
114
+
115
+ self.profileImageView.sd_setImage(with: profilePhotoUrl, placeholderImage: UIImage(named: "placeholderImg"))
116
+
117
+ }
118
+
119
+
120
+
121
+ if user?.uid == Api.User.CURRENT_USER?.uid {
122
+
123
+ followBtn.setTitle("edit", for: .normal)
124
+
125
+ }else{
126
+
127
+ print("updateStateFollowBtn()") // <- 反応する
128
+
129
+ updateStateFollowBtn()
130
+
131
+ }
132
+
133
+ }
134
+
135
+
136
+
137
+ func updateStateFollowBtn() {
138
+
139
+ if user!.isFollowing! {
140
+
141
+ configureUnFollowBtn()
142
+
143
+ print("configureUnFollowBtn()")
144
+
145
+ }else{
146
+
147
+ configureFollowBtn()
148
+
149
+ print("configureFollowBtn()") // <- 反応する
150
+
151
+ }
152
+
153
+ }
154
+
155
+
156
+
157
+ func configureFollowBtn() {
158
+
159
+ followBtn.setTitle("follow", for: .normal)
160
+
161
+
162
+
163
+ // ⬇︎⬇︎⬇︎⬇︎ 反応しない ⬇︎⬇︎⬇︎⬇︎
164
+
165
+ followBtn.addTarget(self, action: #selector(self.followAction), for: .touchUpInside)
166
+
167
+ }
168
+
169
+
170
+
41
- func goToProfileUserVC(userId: String)
171
+ func configureUnFollowBtn() {
172
+
173
+ followBtn.setTitle("unfollow", for: .normal)
174
+
175
+ followBtn.addTarget(self, action: #selector(self.unFollowAction), for: .touchUpInside)
176
+
177
+ }
178
+
179
+
180
+
181
+ func followAction() {
182
+
183
+ print("followAction")
184
+
185
+ if !user!.isFollowing! {
186
+
187
+ Api.follow.REF_FOLLOWING.child(Api.User.CURRENT_USER!.uid).child(user!.uid!).setValue(true)
188
+
189
+ Api.follow.REF_FOLLOWERS.child(user!.uid!).child(Api.User.CURRENT_USER!.uid).setValue(true)
190
+
191
+ configureUnFollowBtn()
192
+
193
+ user!.isFollowing! = true
194
+
195
+ }
196
+
197
+ }
198
+
199
+
200
+
201
+ func unFollowAction() {
202
+
203
+ print("unFollowAction")
204
+
205
+ if user!.isFollowing! {
206
+
207
+ Api.follow.REF_FOLLOWING.child(Api.User.CURRENT_USER!.uid).child(user!.uid!).setValue(NSNull())
208
+
209
+ Api.follow.REF_FOLLOWERS.child(user!.uid!).child(Api.User.CURRENT_USER!.uid).setValue(NSNull())
210
+
211
+ configureFollowBtn()
212
+
213
+ user!.isFollowing! = false
214
+
215
+ }
216
+
217
+ }
42
218
 
43
219
  }
44
220
 
45
-
46
-
47
- class PeopleTableViewCell: UITableViewCell {
48
-
49
-
50
-
51
- @IBOutlet weak var profileImageView: UIImageView!
52
-
53
- @IBOutlet weak var nameLabel: UILabel!
54
-
55
- @IBOutlet weak var followBtn: UIButton!
56
-
57
-
58
-
59
- var delegate: PeopleTableViewCellDelegate?
60
-
61
-
62
-
63
- var user: UserModel? {
64
-
65
- didSet {
66
-
67
- updateView()
68
-
69
- }
70
-
71
- }
72
-
73
-
74
-
75
- func updateView() {
76
-
77
- nameLabel.text = user?.username
78
-
79
- if let profileImageUrlString = user?.profileImageURL {
80
-
81
- let profileImageUrl = URL(string: profileImageUrlString)
82
-
83
- profileImageView.sd_setImage(with: profileImageUrl)
84
-
85
- }
86
-
87
-
88
-
89
- if user!.isFollowing! {
90
-
91
- configureUnFollowBtn()
92
-
93
- }else{
94
-
95
- configureFollowBtn()
96
-
97
- }
98
-
99
- }
100
-
101
-
102
-
103
- func configureFollowBtn() {
104
-
105
- followBtn.setTitle("フォローする", for: .normal)
106
-
107
- // ⬇︎⬇︎⬇︎⬇︎このaddTargetが動かない⬇︎⬇︎⬇︎⬇︎
108
-
109
- followBtn.addTarget(self, action: #selector(self.followAction), for: .touchUpInside)
110
-
111
- }
112
-
113
-
114
-
115
- func configureUnFollowBtn() {
116
-
117
- followBtn.setTitle("フォロー中", for: .normal)
118
-
119
- followBtn.addTarget(self, action: #selector(self.unFollowAction), for: .touchUpInside)
120
-
121
- }
122
-
123
-
124
-
125
- func followAction() {
126
-
127
- if !user!.isFollowing! {
128
-
129
- Api.follow.REF_FOLLOWING.child(Api.User.CURRENT_USER!.uid).child(user!.uid!).setValue(true)
130
-
131
- Api.follow.REF_FOLLOWERS.child(user!.uid!).child(Api.User.CURRENT_USER!.uid).setValue(true)
132
-
133
- configureUnFollowBtn()
134
-
135
- user!.isFollowing! = true
136
-
137
- }
138
-
139
- }
140
-
141
-
142
-
143
- func unFollowAction() {
144
-
145
- if user!.isFollowing! {
146
-
147
- Api.follow.REF_FOLLOWING.child(Api.User.CURRENT_USER!.uid).child(user!.uid!).setValue(NSNull())
148
-
149
- Api.follow.REF_FOLLOWERS.child(user!.uid!).child(Api.User.CURRENT_USER!.uid).setValue(NSNull())
150
-
151
- configureFollowBtn()
152
-
153
- user!.isFollowing! = false
154
-
155
- }
156
-
157
- }
158
-
159
-
160
-
161
- override func awakeFromNib() {
162
-
163
- super.awakeFromNib()
164
-
165
-
166
-
167
- profileImageView.clipsToBounds = true
168
-
169
- profileImageView.layer.cornerRadius = 30
170
-
171
-
172
-
173
-
174
-
175
- let peopleTapGesture = UITapGestureRecognizer(target: self, action: #selector(self.nameLabel_TouchUpInside))
176
-
177
- nameLabel.addGestureRecognizer(peopleTapGesture)
178
-
179
- nameLabel.isUserInteractionEnabled = true
180
-
181
- }
182
-
183
-
184
-
185
- func nameLabel_TouchUpInside() {
186
-
187
- if let userId = user?.uid! {
188
-
189
- delegate?.goToProfileUserVC(userId: userId)
190
-
191
- print("success1")
192
-
193
- }
194
-
195
- }
196
-
197
-
198
-
199
- override func setSelected(_ selected: Bool, animated: Bool) {
200
-
201
- super.setSelected(selected, animated: animated)
202
-
203
-
204
-
205
-
206
-
207
- }
208
-
209
- }
210
-
211
-
212
-
213
221
  ```
214
222
 
215
223
 

3

修正

2019/05/02 04:25

投稿

reeeeet
reeeeet

スコア95

test CHANGED
File without changes
test CHANGED
@@ -221,3 +221,9 @@
221
221
  Xcode 10.0
222
222
 
223
223
  Swift 3.0
224
+
225
+
226
+
227
+
228
+
229
+ すみませんが、よろしくお願い致します。

2

修正

2019/05/01 11:11

投稿

reeeeet
reeeeet

スコア95

test CHANGED
File without changes
test CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
  #code
28
28
 
29
- addTargetが動かない
29
+ **反応しない箇所 -> addTarget**
30
30
 
31
31
  ```Swift
32
32
 
@@ -104,7 +104,7 @@
104
104
 
105
105
  followBtn.setTitle("フォローする", for: .normal)
106
106
 
107
- // このaddTargetが動かない
107
+ // ⬇︎⬇︎⬇︎⬇︎このaddTargetが動かない⬇︎⬇︎⬇︎⬇︎
108
108
 
109
109
  followBtn.addTarget(self, action: #selector(self.followAction), for: .touchUpInside)
110
110
 

1

誤字

2019/05/01 08:56

投稿

reeeeet
reeeeet

スコア95

test CHANGED
File without changes
test CHANGED
@@ -216,7 +216,7 @@
216
216
 
217
217
  # 開発環境
218
218
 
219
- MacOS Mojave 10.14.1
219
+ MacOS Mojave 10.14.4
220
220
 
221
221
  Xcode 10.0
222
222