質問編集履歴

1

説明文の追加と軽微な修正

2019/12/28 14:34

投稿

1101hiroki_n
1101hiroki_n

スコア4

test CHANGED
File without changes
test CHANGED
@@ -24,10 +24,14 @@
24
24
 
25
25
  class SearchViewController: UIViewController {
26
26
 
27
+ //検索ボタンの上下空白
28
+
27
29
  private let buttonVerticalMargin: CGFloat = 60.0
28
30
 
29
31
 
30
32
 
33
+ //APIのための構造体
34
+
31
35
  struct searchingBookInfo {
32
36
 
33
37
  var title: String?
@@ -48,6 +52,8 @@
48
52
 
49
53
 
50
54
 
55
+ //入力欄ひとつ分を表す構造体
56
+
51
57
  struct MainInputStruct {
52
58
 
53
59
  var label: MainInputLabel
@@ -64,6 +70,8 @@
64
70
 
65
71
 
66
72
 
73
+ //入力欄UIのインスタンス郡
74
+
67
75
  private let titleInputLabel: MainInputLabel = MainInputLabel()
68
76
 
69
77
  private let titleInputTextField: MainInputTextField = MainInputTextField()
@@ -108,67 +116,11 @@
108
116
 
109
117
  private let searchButton: MainCenterButton = MainCenterButton()
110
118
 
111
-
112
-
113
- private var searchData: searchingBookInfo = searchingBookInfo(
119
+
114
-
115
- title: nil,
116
-
117
- authors: [],
118
-
119
- publisher: nil,
120
-
121
- edition: nil,
122
-
123
- condition: nil,
124
-
125
- priceUpperLimit: nil,
126
-
127
- ISBNCode: nil,
128
-
129
- )
130
-
131
-
132
-
133
-
134
120
 
135
121
  @objc private func searchButtonEvent(_ sender: MainCenterButton) {
136
122
 
137
- sender.setTitle("検索中", for: UIControl.State.normal)
138
-
139
-
140
-
141
- searchData = searchingBookInfo(
142
-
143
- title: titleInputTextField.text!,
144
-
145
- authors: [authorInputTextField.text!],
146
-
147
- publisher: publisherInputTextField.text!,
148
-
149
- edition: editionInputTextField.text!,
150
-
151
- condition: conditionInputTextField.text!,
152
-
153
- priceUpperLimit: upperLimitInputTextField.text!,
154
-
155
- ISBNCode: isbnCodeInputTextField.text!,
156
-
157
- )
158
-
159
- print(searchData)
160
-
161
- }
162
-
163
-
164
-
165
- override func viewDidLayoutSubviews() {
166
-
167
- super.viewDidLayoutSubviews()
168
-
169
-
170
-
171
- view.layoutIfNeeded()
123
+ //検索ボタン押下処理
172
124
 
173
125
  }
174
126
 
@@ -178,6 +130,10 @@
178
130
 
179
131
  super.viewDidLoad()
180
132
 
133
+
134
+
135
+ //入力欄の配置ViewとScrollView
136
+
181
137
  let searchPageScrollView: UIScrollView = UIScrollView()
182
138
 
183
139
  self.view.addSubview(searchPageScrollView)
@@ -228,6 +184,8 @@
228
184
 
229
185
 
230
186
 
187
+ //検索ボタン
188
+
231
189
  searchButton.setTitle("検索", for: UIControl.State.normal)
232
190
 
233
191
  searchButton.addTarget(self, action: #selector(searchButtonEvent(_:)), for: UIControl.Event.touchUpInside)
@@ -250,6 +208,8 @@
250
208
 
251
209
 
252
210
 
211
+      //入力欄構造体MainInputStructの配列
212
+
253
213
  let mainInputs:[MainInputStruct] = [
254
214
 
255
215
  MainInputStruct(label: titleInputLabel, textField: titleInputTextField, labelText: "タイトル・書籍名", placeholderText: "タイトル・書籍名を入力"),
@@ -270,6 +230,8 @@
270
230
 
271
231
 
272
232
 
233
+ //appendMainInputs()メソッドで配置
234
+
273
235
  self.appendMainInputs(structArray: mainInputs, target: searchPageContentView.topAnchor, firstConstant: (buttonVerticalMargin*2 + 60.0), appendTargetView: searchPageContentView)
274
236
 
275
237
  NSLayoutConstraint.activate([