質問編集履歴
4
画像の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
![
|
13
|
+
![あああ](8ea61e8fa733ecb1ab541f1364934049.png)
|
14
14
|
|
15
15
|
|
16
16
|
|
@@ -189,3 +189,11 @@
|
|
189
189
|
}
|
190
190
|
|
191
191
|
```
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
***
|
196
|
+
|
197
|
+
**高さ制約を挿入したら解決しました**
|
198
|
+
|
199
|
+
![イメージ説明](0f8a7302a35bd329eba1d6ff85195563.png)
|
3
文章を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
## やりたいこと
|
20
20
|
|
21
|
-
labelの高さを自動で調整しつつ、KILabelを使いたい (途中で切れないように)
|
21
|
+
[UIlabelの高さを自動で調整](https://qiita.com/marusy/items/b17eeb72550db5da3fa9)しつつ、[KILabel](https://github.com/Krelborn/KILabel) を使いたい (途中で切れないように)
|
22
22
|
|
23
23
|
|
24
24
|
|
2
文章の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -75,3 +75,117 @@
|
|
75
75
|
|
76
76
|
|
77
77
|
すみませんが、よろしくお願いします。
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
## code
|
84
|
+
|
85
|
+
viewController
|
86
|
+
|
87
|
+
```Swift
|
88
|
+
|
89
|
+
var post = Post()
|
90
|
+
|
91
|
+
var user = User()
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
@IBOutlet weak var tableView: UITableView!
|
96
|
+
|
97
|
+
override func viewDidLoad() {
|
98
|
+
|
99
|
+
super.viewDidLoad()
|
100
|
+
|
101
|
+
tableView.estimatedRowHeight = 521
|
102
|
+
|
103
|
+
tableView.rowHeight = UITableViewAutomaticDimension
|
104
|
+
|
105
|
+
tableView.separatorStyle = .none
|
106
|
+
|
107
|
+
tableView.dataSource = self
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
extension DetailViewController: UITableViewDataSource {
|
114
|
+
|
115
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
116
|
+
|
117
|
+
return 1
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
124
|
+
|
125
|
+
let cell = tableView.dequeueReusableCell(withIdentifier: "PostCell", for: indexPath) as! HomeTableViewCell
|
126
|
+
|
127
|
+
cell.post = post
|
128
|
+
|
129
|
+
cell.user = user
|
130
|
+
|
131
|
+
cell.delegate = self
|
132
|
+
|
133
|
+
return cell
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
```
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
view (HomeTableViewCell)
|
144
|
+
|
145
|
+
```Swift
|
146
|
+
|
147
|
+
@IBOutlet weak var captionLabel: KILabel!
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
var post: Post? {
|
152
|
+
|
153
|
+
didSet {
|
154
|
+
|
155
|
+
updateView()
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
func updateView() {
|
164
|
+
|
165
|
+
captionLabel.numberOfLines = 0
|
166
|
+
|
167
|
+
captionLabel.lineBreakMode = NSLineBreakMode.byWordWrapping
|
168
|
+
|
169
|
+
captionLabel.sizeToFit()
|
170
|
+
|
171
|
+
captionLabel.text = post?.caption
|
172
|
+
|
173
|
+
captionLabel.hashtagLinkTapHandler = { label, string, range in
|
174
|
+
|
175
|
+
let tag = String(string.dropFirst())
|
176
|
+
|
177
|
+
self.delegate?.goToHashTag(tag: tag)
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
if let photoUrlString = post?.photoUrl {
|
182
|
+
|
183
|
+
let photoUrl = URL(string: photoUrlString)
|
184
|
+
|
185
|
+
postImageView.sd_setImage(with: photoUrl)
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
```
|
1
文章を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,9 +30,9 @@
|
|
30
30
|
|
31
31
|
| :-- | :--: |
|
32
32
|
|
33
|
-
| 高さの自動調整 だけ | 機能する |
|
33
|
+
| 高さの自動調整 **だけ** | 機能する |
|
34
34
|
|
35
|
-
| KILabel だけ | 機能する |
|
35
|
+
| KILabel **だけ** | 機能する |
|
36
36
|
|
37
37
|
| KILabel と 高さの自動調整|ダメ|
|
38
38
|
|