質問編集履歴
2
画像の変更、やりたい事の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
```
|
60
60
|
|
61
|
-

|
62
62
|
|
63
63
|
|
64
64
|
|
@@ -66,7 +66,7 @@
|
|
66
66
|
|
67
67
|
pickerとtextFieldの位置を上下逆にしたいです。
|
68
68
|
|
69
|
-
それとtextFieldを複数にするとこういったくっついた形になってしまうのですがそ
|
69
|
+
それとtextFieldを複数にするとこういったくっついた形になってしまうのですがそ
|
70
70
|
|
71
71
|
|
72
72
|
|
@@ -80,15 +80,7 @@
|
|
80
80
|
|
81
81
|
alert内にpickerとtextを上下逆にしたいのですがどうすればいいか分からなくて困っています。
|
82
82
|
|
83
|
-
あとpickerがアラート内をはみ出していていてアラート内に二つのpickerをおさめる方法が分からなくて困っています。
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-

|
88
|
-
|
89
|
-
**イメージ**
|
90
|
-
|
91
|
-
textFieldの隙間
|
83
|
+
それとalert内のtextFieldとpickerViewの間の隙間を出来るだけ無くしたいです。
|
92
84
|
|
93
85
|
|
94
86
|
|
1
文法の修正とスクショの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,24 +1,26 @@
|
|
1
1
|
```swift
|
2
2
|
|
3
|
-
import UIKit
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
class ViewController: UIViewController,UIPickerViewDelegate,UIPickerViewDataSource{
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
var pickerView = UIPickerView()
|
14
|
-
|
15
|
-
let number = ["1","2","3","4","5"]
|
16
|
-
|
17
|
-
@IBOutlet weak var mytableView: UITableView!
|
18
|
-
|
19
|
-
|
3
|
+
@IBAction func btr(_ sender: Any) {
|
20
4
|
|
21
5
|
let alert = UIAlertController(title: "値を入力してください", message: "\n\n\n\n\n\n\n\n", preferredStyle: .alert)
|
6
|
+
|
7
|
+
// テキストフィールドを追加
|
8
|
+
|
9
|
+
alert.addTextField(configurationHandler: {(textField: UITextField!) -> Void in
|
10
|
+
|
11
|
+
textField.placeholder = "買ったもの"
|
12
|
+
|
13
|
+
})
|
14
|
+
|
15
|
+
//二個目
|
16
|
+
|
17
|
+
alert.addTextField(configurationHandler: {(textField: UITextField!) -> Void in
|
18
|
+
|
19
|
+
textField.placeholder = "金額"
|
20
|
+
|
21
|
+
})
|
22
|
+
|
23
|
+
|
22
24
|
|
23
25
|
let saveAction = UIAlertAction(title: "OK", style: .default) { (action:UIAlertAction!) -> Void in
|
24
26
|
|
@@ -34,7 +36,7 @@
|
|
34
36
|
|
35
37
|
//PickerView
|
36
38
|
|
37
|
-
pickerView = UIPickerView(frame:CGRect(x:0, y:50, width:view.bounds.width*0.6, height:50)) // 配置、サイズ
|
39
|
+
pickerView = UIPickerView(frame:CGRect(x:0, y:50, width:view.bounds.width*0.6, height:150)) // 配置、サイズ
|
38
40
|
|
39
41
|
pickerView.frame = CGRect(x:0, y:0, width:view.bounds.width, height:150)
|
40
42
|
|
@@ -54,96 +56,40 @@
|
|
54
56
|
|
55
57
|
}
|
56
58
|
|
57
|
-
// PickerViewの列数
|
58
|
-
|
59
|
-
func numberOfComponents(in pickerView: UIPickerView) -> Int {
|
60
|
-
|
61
|
-
return 1
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
// PickerViewの行数
|
68
|
-
|
69
|
-
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
|
70
|
-
|
71
|
-
return number.count
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
// PickerViewの項目
|
78
|
-
|
79
|
-
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
|
80
|
-
|
81
|
-
return number[row]
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
// PickerViewの項目選択時
|
88
|
-
|
89
|
-
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
override func viewDidLoad() {
|
100
|
-
|
101
|
-
super.viewDidLoad()
|
102
|
-
|
103
|
-
// Do any additional setup after loading the view, typically from a nib.
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
override func didReceiveMemoryWarning() {
|
110
|
-
|
111
|
-
super.didReceiveMemoryWarning()
|
112
|
-
|
113
|
-
// Dispose of any resources that can be recreated.
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
59
|
```
|
126
60
|
|
127
|
-

|
128
62
|
|
129
63
|
|
130
64
|
|
131
65
|
~~**~~やりたいこと~~**~~
|
132
66
|
|
133
|
-
|
67
|
+
pickerとtextFieldの位置を上下逆にしたいです。
|
134
68
|
|
135
|
-
|
69
|
+
それとtextFieldを複数にするとこういったくっついた形になってしまうのですがそれをtextFieldとtextFieldの間に少し空白の隙間を作れるようにしたいです。
|
136
|
-
|
137
|
-
ex)100円、120ドル、150ユーロ
|
138
70
|
|
139
71
|
|
140
72
|
|
141
73
|
**自分出来たところ**
|
142
74
|
|
143
|
-
alert内にpickerを設置するところまで出来た
|
75
|
+
alert内にpickerと追加でtextFieldまでを設置するところまで出来た
|
144
76
|
|
145
77
|
|
146
78
|
|
147
79
|
**困っているところ**
|
148
80
|
|
149
|
-
alert内にpickerとtextを
|
81
|
+
alert内にpickerとtextを上下逆にしたいのですがどうすればいいか分からなくて困っています。
|
82
|
+
|
83
|
+
あとpickerがアラート内をはみ出していていてアラート内に二つのpickerをおさめる方法が分からなくて困っています。
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+

|
88
|
+
|
89
|
+
**イメージ**
|
90
|
+
|
91
|
+
textFieldの隙間はこんな感じに開けれるようにしたいです。
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
versionはswift4で開発しています。
|