swift
1@IBAction func btr(_ sender: Any) { 2 let alert = UIAlertController(title: "値を入力してください", message: "\n\n\n\n\n\n\n\n", preferredStyle: .alert) 3 // テキストフィールドを追加 4 alert.addTextField(configurationHandler: {(textField: UITextField!) -> Void in 5 textField.placeholder = "買ったもの" 6 }) 7 //二個目 8 alert.addTextField(configurationHandler: {(textField: UITextField!) -> Void in 9 textField.placeholder = "金額" 10 }) 11 12 let saveAction = UIAlertAction(title: "OK", style: .default) { (action:UIAlertAction!) -> Void in 13 self.mytableView.reloadData() 14 } 15 let cancelAction = UIAlertAction(title: "キャンセル", style: .default) { (action:UIAlertAction!) -> Void in 16 } 17 18 //PickerView 19 pickerView = UIPickerView(frame:CGRect(x:0, y:50, width:view.bounds.width*0.6, height:150)) // 配置、サイズ 20 pickerView.frame = CGRect(x:0, y:0, width:view.bounds.width, height:150) 21 pickerView.dataSource = self 22 pickerView.delegate = self 23 alert.view.addSubview(pickerView) 24 25 alert.addAction(saveAction) 26 alert.addAction(cancelAction) 27 present(alert, animated: true, completion: nil) 28 }
やりたいこと
pickerとtextFieldの位置を上下逆にしたいです。
それとtextFieldを複数にするとこういったくっついた形になってしまうのですがそ
自分出来たところ
alert内にpickerと追加でtextFieldまでを設置するところまで出来た
困っているところ
alert内にpickerとtextを上下逆にしたいのですがどうすればいいか分からなくて困っています。
それとalert内のtextFieldとpickerViewの間の隙間を出来るだけ無くしたいです。
versionはswift4で開発しています。




回答2件
あなたの回答
tips
プレビュー