質問編集履歴
4
こードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,11 +2,21 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
collectinviewのcellを押した時にUserPostViewControllerというクラスへ画面遷移し
|
5
|
+
collectinviewのcellを押した時にUserPostViewControllerというクラスへ画面遷移し移動先(UserPostViewController)のcommentTextViewにUserPageViewControllerのcommentText を入れたいです。
|
6
|
+
|
7
|
+
|
6
8
|
|
7
9
|
|
8
10
|
|
9
11
|
performSegueのwithIdentifier が "toPost"であり、遷移先のクラスがUserPostViewControllerであるのも確認しました。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
10
20
|
|
11
21
|
|
12
22
|
|
@@ -114,4 +124,60 @@
|
|
114
124
|
|
115
125
|
```
|
116
126
|
|
127
|
+
移動先
|
128
|
+
|
129
|
+
```ここに言語を入力
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
class UserPostViewController: UIViewController {
|
134
|
+
|
135
|
+
var commentText:String?
|
136
|
+
|
137
|
+
@IBOutlet var userImageView: UIImageView!
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
@IBOutlet var userNameLabel: UILabel!
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
@IBOutlet var photoImageView: UIImageView!
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
@IBOutlet var commentTextView: UITextView!
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
@IBOutlet var timestampLabel: UILabel!
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
override func viewDidLoad() {
|
162
|
+
|
163
|
+
super.viewDidLoad()
|
164
|
+
|
165
|
+
commentTextView.text = commentText
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
userImageView.layer.cornerRadius = userImageView.bounds.width / 2.0
|
170
|
+
|
171
|
+
userImageView.clipsToBounds = true
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
```
|
178
|
+
|
117
|
-
![イメージ説明](
|
179
|
+
![イメージ説明](d4f80f5032353bfd46c5f188079766b3.png)
|
180
|
+
|
181
|
+
実行後
|
182
|
+
|
183
|
+
![イメージ説明](db0153b880cf78481e65c6db284267ce.png)
|
3
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,10 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
27
31
|
どういった対処が必要でしょうか??
|
28
32
|
|
29
33
|
|
@@ -36,7 +40,57 @@
|
|
36
40
|
|
37
41
|
|
38
42
|
|
43
|
+
|
44
|
+
|
39
45
|
```ここに言語を入力
|
46
|
+
|
47
|
+
class UserPageViewController: UIViewController, UICollectionViewDataSource ,UICollectionViewDelegate{
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
var posts = [Post]()
|
52
|
+
|
53
|
+
var commentText :String = ""
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
@IBOutlet var userImageView: UIImageView!
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
@IBOutlet var userDisplayNameLabel: UILabel!
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
@IBOutlet var userIntroductionTextView: UITextView!
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
@IBOutlet var photoCollectionView : UICollectionView!
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
@IBOutlet var postCountLabel: UILabel!
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
@IBOutlet var followerCountLabel: UILabel!
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
@IBOutlet var followingCountLabel: UILabel!
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
40
94
|
|
41
95
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
42
96
|
|
@@ -59,3 +113,5 @@
|
|
59
113
|
}
|
60
114
|
|
61
115
|
```
|
116
|
+
|
117
|
+
![イメージ説明](abb92c9612a225a27dc97817f34689f4.png)
|
2
こードの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,6 +28,14 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
+
追記
|
32
|
+
|
33
|
+
初めに投稿したものはsegueのdestinationの書き方が間違えており、今回編集済みです。
|
34
|
+
|
35
|
+
しかし、遷移できなかったので、アドバイス頂けると幸いです。
|
36
|
+
|
37
|
+
|
38
|
+
|
31
39
|
```ここに言語を入力
|
32
40
|
|
33
41
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
1
codeに書き換え
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,26 +2,52 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
collectinviewのcellを押した時にUserPostViewControllerというクラスへ画面遷移し
|
5
|
+
collectinviewのcellを押した時にUserPostViewControllerというクラスへ画面遷移し,commentTextという変数にposts[indexPath.row].textを入れたいです。
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
performSegueのwithIdentifier が "toPost"であり、遷移先のクラスがUserPostViewControllerであるのも確認しました。
|
10
10
|
|
11
|
-
segue.destinationのところで
|
12
11
|
|
13
|
-
Expression of type 'UserPostViewController' is unused
|
14
12
|
|
15
|
-
|
13
|
+
しかしcellを押しても遷移すらしてくれないです。
|
16
14
|
|
17
15
|
|
18
16
|
|
19
17
|
|
20
18
|
|
21
|
-
どういった対処が必要でしょうか?
|
22
19
|
|
23
20
|
|
24
21
|
|
25
22
|
|
26
23
|
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
どういった対処が必要でしょうか??
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
```ここに言語を入力
|
32
|
+
|
33
|
+
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
34
|
+
|
35
|
+
commentText = posts[indexPath.row].text
|
36
|
+
|
37
|
+
performSegue(withIdentifier: "toPost", sender: nil)
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
42
|
+
|
43
|
+
if segue.identifier == "toPost"{
|
44
|
+
|
45
|
+
let userPostViewController = segue.destination as! UserPostViewController
|
46
|
+
|
27
|
-
|
47
|
+
userPostViewController.commentText = commentText
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
```
|