回答編集履歴
5
s
answer
CHANGED
@@ -8,23 +8,41 @@
|
|
8
8
|
---
|
9
9
|
|
10
10
|
```swift
|
11
|
+
|
11
12
|
import UIKit
|
12
13
|
import TTTAttributedLabel
|
13
14
|
|
14
|
-
class ViewController: UIViewController,
|
15
|
+
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
|
15
16
|
|
16
|
-
@IBOutlet weak var
|
17
|
+
@IBOutlet weak var tableView: UITableView!
|
17
18
|
|
18
|
-
override func viewDidLoad() {
|
19
|
-
super.viewDidLoad()
|
20
|
-
|
21
|
-
|
19
|
+
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
22
|
-
label1.text = "URLにタップできます。\nhttps://www.google.co.jp/"
|
23
|
-
|
20
|
+
return 3
|
24
21
|
}
|
25
22
|
|
23
|
+
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
24
|
+
if let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath as IndexPath) as? CustomCell {
|
25
|
+
cell.setText(text: "URLにタップできます。\nhttps://www.google.co.jp/")
|
26
|
+
return cell
|
27
|
+
}
|
28
|
+
return UITableViewCell()
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
class CustomCell: UITableViewCell, TTTAttributedLabelDelegate {
|
33
|
+
|
34
|
+
@IBOutlet weak var label: TTTAttributedLabel!
|
35
|
+
|
36
|
+
func setText(text: String) {
|
37
|
+
label.enabledTextCheckingTypes = NSTextCheckingResult.CheckingType.link.rawValue
|
38
|
+
label.text = text
|
39
|
+
label.delegate = self
|
40
|
+
}
|
41
|
+
|
26
42
|
func attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) {
|
27
43
|
print("Tapped!")
|
28
44
|
}
|
29
45
|
}
|
30
|
-
```
|
46
|
+
```
|
47
|
+
|
48
|
+

|
4
s
answer
CHANGED
@@ -2,4 +2,29 @@
|
|
2
2
|
|
3
3
|

|
4
4
|
|
5
|
-
それでも解決しなければコンソールに出ているエラーをすべて載せてください。
|
5
|
+
それでも解決しなければコンソールに出ているエラーをすべて載せてください。
|
6
|
+
|
7
|
+
回答追記
|
8
|
+
---
|
9
|
+
|
10
|
+
```swift
|
11
|
+
import UIKit
|
12
|
+
import TTTAttributedLabel
|
13
|
+
|
14
|
+
class ViewController: UIViewController, TTTAttributedLabelDelegate {
|
15
|
+
|
16
|
+
@IBOutlet weak var label1: TTTAttributedLabel!
|
17
|
+
|
18
|
+
override func viewDidLoad() {
|
19
|
+
super.viewDidLoad()
|
20
|
+
|
21
|
+
label1.enabledTextCheckingTypes = NSTextCheckingResult.CheckingType.link.rawValue
|
22
|
+
label1.text = "URLにタップできます。\nhttps://www.google.co.jp/"
|
23
|
+
label1.delegate = self
|
24
|
+
}
|
25
|
+
|
26
|
+
func attributedLabel(_ label: TTTAttributedLabel!, didSelectLinkWith url: URL!) {
|
27
|
+
print("Tapped!")
|
28
|
+
}
|
29
|
+
}
|
30
|
+
```
|
3
s
answer
CHANGED
@@ -1,3 +1,5 @@
|
|
1
1
|
`Storyboard` or `xib`にラベルを配置していると思いますが、そのラベルの`Custom Class` は`TTTAttributedLabel`になっているでしょうか?
|
2
2
|
|
3
|
-

|
3
|
+

|
4
|
+
|
5
|
+
それでも解決しなければコンソールに出ているエラーをすべて載せてください。
|
2
s
answer
CHANGED
@@ -1,1 +1,3 @@
|
|
1
|
-
`Storyboard` or `xib`にラベルを配置していると思いますが、そのラベルの`Custom Class` は`TTTAttributedLabel`になっているでしょうか?
|
1
|
+
`Storyboard` or `xib`にラベルを配置していると思いますが、そのラベルの`Custom Class` は`TTTAttributedLabel`になっているでしょうか?
|
2
|
+
|
3
|
+

|
1
s
answer
CHANGED
@@ -1,5 +1,1 @@
|
|
1
|
-
> エラー文には
|
2
|
-
|
1
|
+
`Storyboard` or `xib`にラベルを配置していると思いますが、そのラベルの`Custom Class` は`TTTAttributedLabel`になっているでしょうか?
|
3
|
-
|
4
|
-
エラーにはおそらく`TTTAttributedLabel`のライブラリは関係ないとおもいます。
|
5
|
-
それ以外のコンソールに表示されているエラー文言を追記してください。
|