swiftで日付を変更する
日付を変更するアプリを作成したいのですが以下のコードでエラー(signal SIGABRT)が出ます。
大変お手数ですがアドバイス頂けないでしょうか?
import UIKit
class ViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate,UITextFieldDelegate {
@IBOutlet weak var Picture1: UIButton!
@IBOutlet weak var Pictureimage1: UIImageView!
@IBOutlet weak var Date: UILabel!
@IBOutlet weak var Name: UILabel!
@IBOutlet weak var WO: UILabel!
@IBOutlet weak var Card: UILabel!
@IBOutlet weak var SelectDate: UITextField!
@IBOutlet weak var text1: UITextField!
@IBOutlet weak var text2: UITextField!
@IBOutlet weak var text3: UITextField!
@IBOutlet weak var but: UIButton!
@IBOutlet weak var sub: UILabel!
let nowDate = NSDate()
let dateFormat = DateFormatter()
let inputDatePicker = UIDatePicker()
override func viewDidLoad() {
super.viewDidLoad()
dateFormat.dateFormat = "yyyy/MM/dd"
self.SelectDate.text = dateFormat.string(from: nowDate as Date)
self.SelectDate.delegate = self
inputDatePicker.datePickerMode = UIDatePickerMode.date
self.SelectDate.inputView = inputDatePicker
let pickerToolBar = UIToolbar(frame: CGRect(x:0, y:self.view.frame.size.height/6, width: self.view.frame.size.width, height: 40.0))
pickerToolBar.layer.position = CGPoint(x: self.view.frame.size.width/2, y: self.view.frame.size.height-20.0)
pickerToolBar.barStyle = .blackTranslucent
pickerToolBar.tintColor = UIColor.white
pickerToolBar.backgroundColor = UIColor.black
let spaceBarBtn = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace,target: self,action: Selector(("a:")))
let toolBarBtn = UIBarButtonItem(title: "OK", style: .done, target: self, action: Selector(("toolBarBtnPush:")))
pickerToolBar.items = [spaceBarBtn, toolBarBtn]
self.SelectDate.inputAccessoryView = pickerToolBar
}
func toolBarBtnPush(sender: UIBarButtonItem){
let pickerDate = inputDatePicker.date
self.SelectDate.text = dateFormat.string(from: pickerDate as Date)
self.view.endEditing(true)
}
}