回答編集履歴
1
サンプルコード追加
test
CHANGED
@@ -47,3 +47,81 @@
|
|
47
47
|
```
|
48
48
|
|
49
49
|
とするだけでよさそうに思います。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
---
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
(7/2 0:37 サンプルコード追加)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
``` swift
|
62
|
+
|
63
|
+
var articles: [ArticleViewController] = [ArticleViewController()]
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
override func viewDidLoad() {
|
68
|
+
|
69
|
+
super.viewDidLoad()
|
70
|
+
|
71
|
+
getCategories()
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
private func getCategories() {
|
78
|
+
|
79
|
+
Alamofire.request(Constant.Url.categoryUrl, method: .get, encoding: JSONEncoding.default).responseJSON { response in
|
80
|
+
|
81
|
+
switch response.result {
|
82
|
+
|
83
|
+
case .success:
|
84
|
+
|
85
|
+
guard let object = response.result.value else { return }
|
86
|
+
|
87
|
+
let json:JSON = JSON(object)
|
88
|
+
|
89
|
+
json.forEach { (_, json) in
|
90
|
+
|
91
|
+
self.categories.append(json["name"].stringValue)
|
92
|
+
|
93
|
+
self.categoriesId.append(json["id"].stringValue)
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
self.articles = []
|
98
|
+
|
99
|
+
for i in 0..<self.categories.count {
|
100
|
+
|
101
|
+
self.articles.append(ArticleViewController())
|
102
|
+
|
103
|
+
self.articles[i].categoryInfo = IndicatorInfo(title: self.categories[i])
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
self.reloadPagerTabStripView()
|
108
|
+
|
109
|
+
case .failure:
|
110
|
+
|
111
|
+
print("error")
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
|
122
|
+
|
123
|
+
return articles
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
```
|